mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 13:32:15 +00:00
Merge branch 'vagrant' into hotfixes
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -99,4 +99,5 @@ atlassian-ide-plugin.xml
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
crashlytics-build.properties
|
||||
.vagrant
|
||||
|
||||
@@ -9,7 +9,9 @@ from django.utils.encoding import python_2_unicode_compatible
|
||||
import reversion
|
||||
import string
|
||||
import random
|
||||
from collections import Counter
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
@@ -91,9 +93,13 @@ class Person(models.Model, RevisionMixin):
|
||||
def organisations(self):
|
||||
o = []
|
||||
for e in Event.objects.filter(person=self).select_related('organisation'):
|
||||
if e.organisation and e.organisation not in o:
|
||||
if e.organisation:
|
||||
o.append(e.organisation)
|
||||
return o
|
||||
|
||||
#Count up occurances and put them in descending order
|
||||
c = Counter(o)
|
||||
stats = c.most_common()
|
||||
return stats
|
||||
|
||||
@property
|
||||
def latest_events(self):
|
||||
@@ -131,9 +137,13 @@ class Organisation(models.Model, RevisionMixin):
|
||||
def persons(self):
|
||||
p = []
|
||||
for e in Event.objects.filter(organisation=self).select_related('person'):
|
||||
if e.person and e.person not in p:
|
||||
if e.person:
|
||||
p.append(e.person)
|
||||
return p
|
||||
|
||||
#Count up occurances and put them in descending order
|
||||
c = Counter(p)
|
||||
stats = c.most_common()
|
||||
return stats
|
||||
|
||||
@property
|
||||
def latest_events(self):
|
||||
@@ -357,6 +367,20 @@ class Event(models.Model, RevisionMixin):
|
||||
def __str__(self):
|
||||
return unicode(self.pk) + ": " + self.name
|
||||
|
||||
def clean(self):
|
||||
if self.end_date and self.start_date > self.end_date:
|
||||
raise ValidationError('Unless you\'ve invented time travel, the event can\'t finish before it has started.')
|
||||
|
||||
startEndSameDay = not self.end_date or self.end_date == self.start_date
|
||||
hasStartAndEnd = self.has_start_time and self.has_end_time
|
||||
if startEndSameDay and hasStartAndEnd and self.start_time > self.end_time:
|
||||
raise ValidationError('Unless you\'ve invented time travel, the event can\'t finish before it has started.')
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
"""Call :meth:`full_clean` before saving."""
|
||||
self.full_clean()
|
||||
super(Event, self).save(*args, **kwargs)
|
||||
|
||||
class Meta:
|
||||
permissions = (
|
||||
('view_event', 'Can view Events'),
|
||||
|
||||
@@ -47,6 +47,7 @@ class EventCreate(generic.CreateView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(EventCreate, self).get_context_data(**kwargs)
|
||||
context['edit'] = True
|
||||
context['currentVAT'] = models.VatRate.objects.current_rate()
|
||||
|
||||
form = context['form']
|
||||
if re.search('"-\d+"', form['items_json'].value()):
|
||||
|
||||
BIN
RIGS/static/imgs/paperwork/corner-bl.jpg
Normal file
BIN
RIGS/static/imgs/paperwork/corner-bl.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
BIN
RIGS/static/imgs/paperwork/corner-tr.jpg
Normal file
BIN
RIGS/static/imgs/paperwork/corner-tr.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
@@ -82,7 +82,8 @@
|
||||
<template > {# Note: page is 595x842 points (1 point=1/72in) #}
|
||||
<pageTemplate id="Headed" >
|
||||
<pageGraphics>
|
||||
<image file="RIGS/static/imgs/paperwork/corner.jpg" x="395" y="642" height="200" width="200"/>
|
||||
<image file="RIGS/static/imgs/paperwork/corner-tr-su.jpg" x="395" y="642" height="200" width="200"/>
|
||||
<image file="RIGS/static/imgs/paperwork/corner-bl.jpg" x="0" y="0" height="200" width="200"/>
|
||||
|
||||
{# logo positioned 42 from left, 33 from top #}
|
||||
<image file="RIGS/static/imgs/paperwork/tec-logo.jpg" x="42" y="719" height="90" width="84"/>
|
||||
@@ -108,6 +109,9 @@
|
||||
|
||||
<pageTemplate id="Main">
|
||||
<pageGraphics>
|
||||
<image file="RIGS/static/imgs/paperwork/corner-tr.jpg" x="395" y="642" height="200" width="200"/>
|
||||
<image file="RIGS/static/imgs/paperwork/corner-bl.jpg" x="0" y="0" height="200" width="200"/>
|
||||
|
||||
<setFont name="OpenSans" size="10"/>
|
||||
{% if not invoice %}<drawCenteredString x="302.5" y="50">[{{ copy }} Copy]</drawCenteredString>{% endif %}
|
||||
<drawCenteredString x="302.5" y="38">[Page <pageNumber/> of <getName id="lastPage" default="0" />]</drawCenteredString>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<b>{{object.start_date|date:"D jS N Y"}}</b>
|
||||
</para>
|
||||
|
||||
<keepInFrame maxHeight="30">
|
||||
<keepInFrame>
|
||||
<para style="style.event_description">
|
||||
{{ object.description|default_if_none:""|linebreaksbr }}
|
||||
</para>
|
||||
@@ -268,7 +268,7 @@
|
||||
|
||||
<para style="blockPara">
|
||||
<b>
|
||||
Conditions of hire available on request or on the TEC PA & Lighting website. E&OE
|
||||
Conditions of hire attached and available on the TEC PA & Lighting website. E&OE
|
||||
</b>
|
||||
</para>
|
||||
|
||||
@@ -295,7 +295,7 @@
|
||||
|
||||
<para style="blockPara">
|
||||
<b>
|
||||
Conditions of hire available on request or on the TEC PA & Lighting website. E&OE
|
||||
Conditions of hire attached and available on the TEC PA & Lighting website. E&OE
|
||||
</b>
|
||||
</para>
|
||||
|
||||
|
||||
@@ -29,8 +29,13 @@
|
||||
<td colspan="2">£ <span id="sumtotal">{{object.sum_total|default:0|floatformat:2}}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td id="vat-rate" data-rate="{{object.vat_rate.rate}}">VAT @
|
||||
{{object.vat_rate.as_percent|floatformat|default:"TBD"}}%</td>
|
||||
{% if not object.pk %}
|
||||
<td id="vat-rate" data-rate="{{currentVAT.rate}}">VAT @
|
||||
{{currentVAT.as_percent|floatformat}}% (TBC)</td>
|
||||
{% else %}
|
||||
<td id="vat-rate" data-rate="{{object.vat_rate.rate}}">VAT @
|
||||
{{object.vat_rate.as_percent|floatformat|default:"TBD"}}%</td>
|
||||
{% endif %}
|
||||
<td colspan="2">£ <span id="vat">{{object.vat|default:0|floatformat:2}}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -1,82 +1,109 @@
|
||||
{% extends request.is_ajax|yesno:"base_ajax.html,base.html" %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block title %}{{ object.name }}{% endblock %}
|
||||
{% block title %}Organisation | {{ object.name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if not request.is_ajax %}
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
<h3>{{ object.name }}<br/>
|
||||
<span class="small"><a href="{% url 'organisation_history' object.pk %}" title="View Revision History">
|
||||
Last edited at {{ object.last_edited_at|date:"d/m/Y H:i" }} by {{ object.last_edited_by.name }}
|
||||
</a></span>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<a href="{% url 'organisation_update' object.pk %}" class="btn btn-primary">Edit <span
|
||||
class="glyphicon glyphicon-pencil"></span></a>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
{% if not request.is_ajax %}
|
||||
<div class="col-sm-12">
|
||||
<h1>Organisation | {{ object.name }}</h1>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 text-right">
|
||||
<div class="btn-group btn-page">
|
||||
<a href="{% url 'organisation_update' object.pk %}" class="btn btn-default"><span
|
||||
class="glyphicon glyphicon-pencil"></span> Edit</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="col-sm-6">
|
||||
<h4>Details</h4>
|
||||
<dl class="dl-horizontal">
|
||||
<dt>Name</dt>
|
||||
<dd>{{ object.name }}</dd>
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading">Organisation Details</div>
|
||||
<div class="panel-body">
|
||||
<dl class="dl-horizontal">
|
||||
<dt>Name</dt>
|
||||
<dd>{{ object.name }}</dd>
|
||||
|
||||
<dt>Phone</dt>
|
||||
<dd><a href="tel:{{ object.phone }}">{{ object.phone }}</a></dd>
|
||||
<dt>Phone</dt>
|
||||
<dd><a href="tel:{{ object.phone }}">{{ object.phone }}</a></dd>
|
||||
|
||||
<dt>Email</dt>
|
||||
<dd><a href="mailto:{{ object.email }}">{{ object.email }}</a></dd>
|
||||
<dt>Email</dt>
|
||||
<dd><a href="mailto:{{ object.email }}"><span class="overflow-ellipsis">{{ object.email }}</span></a></dd>
|
||||
|
||||
<dt>Address</dt>
|
||||
<dd>{{ object.address|linebreaksbr }}</dd>
|
||||
<dt>Address</dt>
|
||||
<dd>{{ object.address|linebreaksbr }}</dd>
|
||||
|
||||
<dt>Notes</dt>
|
||||
<dd>{{ object.notes|linebreaksbr }}</dd>
|
||||
<dt>Notes</dt>
|
||||
<dd>{{ object.notes|linebreaksbr }}</dd>
|
||||
|
||||
<dt>Union Account</dt>
|
||||
<dd>{{ object.union_account|yesno|capfirst }}</dd>
|
||||
</dl>
|
||||
<dt>Union Account</dt>
|
||||
<dd>{{ object.union_account|yesno|capfirst }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<h4>People</h4>
|
||||
<ul class="list-unstyled">
|
||||
{% for person in object.persons %}
|
||||
<li><a href="{% url 'person_detail' person.pk %}">{{ person.name }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Associated People</div>
|
||||
<div class="panel-body">
|
||||
<div class="list-group">
|
||||
{% for person,count in object.persons %}
|
||||
<a class="list-group-item" href="{% url 'person_detail' person.pk %}">{{ person.pk|stringformat:"05d" }} | {{ person.name }} <span class="badge" title="{{count}} events with {{person.name}} for {{object.name}}">{{count}}</span></a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<h4>Events</h4>
|
||||
{% with object.latest_events as events %}
|
||||
{% include 'RIGS/event_table.html' %}
|
||||
{% endwith %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Associated Events</div>
|
||||
<div class="panel-body">
|
||||
{% with object.latest_events as events %}
|
||||
{% include 'RIGS/event_table.html' %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% if not request.is_ajax %}
|
||||
<div class="row">
|
||||
<div class="col-sm-12 text-right">
|
||||
<div class="btn-group btn-page">
|
||||
<a href="{% url 'organisation_update' object.pk %}" class="btn btn-default"><span
|
||||
class="glyphicon glyphicon-pencil"></span> Edit</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="{% url 'organisation_history' object.pk %}" title="View Revision History">
|
||||
Last edited {{ object.last_edited_at }} by {{ object.last_edited_by.name }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% if request.is_ajax %}
|
||||
{% block footer %}
|
||||
<div class="row">
|
||||
<div class="col-sm-10 align-left">
|
||||
<a href="{% url 'organisation_history' object.pk %}" title="View Revision History">
|
||||
Last edited at {{ object.last_edited_at }} by {{ object.last_edited_by.name }}
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<div class="pull-right">
|
||||
<a href="{% url 'organisation_update' object.pk %}" class="btn btn-primary">Edit <span
|
||||
class="glyphicon glyphicon-pencil"></span></a>
|
||||
<div class="col-sm-12 text-right">
|
||||
<div class="btn-group btn-page">
|
||||
<a href="{% url 'organisation_detail' object.pk %}" class="btn btn-default"><span
|
||||
class="glyphicon glyphicon-eye-open"></span> Open Page</a>
|
||||
<a href="{% url 'organisation_update' object.pk %}" class="btn btn-default"><span
|
||||
class="glyphicon glyphicon-pencil"></span> Edit</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="{% url 'organisation_history' object.pk %}" title="View Revision History">
|
||||
Last edited {{ object.last_edited_at }} by {{ object.last_edited_by.name }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends request.is_ajax|yesno:'base_ajax.html,base.html' %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block title %}{% if object.pk %}Edit {{ object.name }}{% else %}Add Person{% endif %}{% endblock %}
|
||||
{% block title %}{% if object.pk %}Edit {{ object.name }}{% else %}Add Organisation{% endif %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-sm-offset-1 col-sm-10">
|
||||
|
||||
@@ -1,74 +1,106 @@
|
||||
{% extends request.is_ajax|yesno:"base_ajax.html,base.html" %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block title %}{{ object.name }}{% endblock %}
|
||||
{% block title %}Person | {{ object.name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<h4>Details</h4>
|
||||
{% if not request.is_ajax %}
|
||||
<h3>{{ object.name }}<br/>
|
||||
<span class="small"><a href="{% url 'person_history' object.pk %}" title="View Revision History">
|
||||
Last edited at {{ object.last_edited_at|date:"d/m/Y H:i" }} by {{ object.last_edited_by.name }}
|
||||
</a></span>
|
||||
</h3>
|
||||
<div class="pull-right">
|
||||
<a href="{% url 'person_update' object.pk %}" class="btn btn-primary">Edit <span
|
||||
class="glyphicon glyphicon-pencil"></span></a>
|
||||
{% if not request.is_ajax %}
|
||||
<div class="col-sm-12">
|
||||
<h1>Person | {{ object.name }}</h1>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 text-right">
|
||||
<div class="btn-group btn-page">
|
||||
<a href="{% url 'person_update' object.pk %}" class="btn btn-default"><span
|
||||
class="glyphicon glyphicon-pencil"></span> Edit</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="">
|
||||
<dl class="dl-horizontal">
|
||||
<dt>Name</dt>
|
||||
<dd>{{ object.name }}</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="col-sm-6">
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading">Person Details</div>
|
||||
<div class="panel-body">
|
||||
<dl class="dl-horizontal">
|
||||
<dt>Name</dt>
|
||||
<dd>{{ object.name }}</dd>
|
||||
|
||||
<dt>Phone</dt>
|
||||
<dd><a href="tel:{{ object.phone }}">{{ object.phone }}</a></dd>
|
||||
<dt>Phone</dt>
|
||||
<dd><a href="tel:{{ object.phone }}">{{ object.phone }}</a></dd>
|
||||
|
||||
<dt>Email</dt>
|
||||
<dd><a href="mailto:{{ object.email }}">{{ object.email }}</a></dd>
|
||||
<dt>Email</dt>
|
||||
<dd><a href="mailto:{{ object.email }}"><span class="overflow-ellipsis">{{ object.email }}</span></a></dd>
|
||||
|
||||
<dt>Address</dt>
|
||||
<dd>{{ object.address|linebreaksbr }}</dd>
|
||||
<dt>Address</dt>
|
||||
<dd>{{ object.address|linebreaksbr }}</dd>
|
||||
|
||||
<dt>Notes</dt>
|
||||
<dd>{{ object.notes|linebreaksbr }}</dd>
|
||||
</dl>
|
||||
<dt>Notes</dt>
|
||||
<dd>{{ object.notes|linebreaksbr }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<h4>Organisations</h4>
|
||||
<ul class="list-unstyled">
|
||||
{% for organisation in object.organisations %}
|
||||
<li><a href="{% url 'organisation_detail' organisation.pk %}">{{ organisation.name }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Associated Organisations</div>
|
||||
<div class="panel-body">
|
||||
<div class="list-group">
|
||||
{% for organisation,count in object.organisations %}
|
||||
<a class="list-group-item" href="{% url 'organisation_detail' organisation.pk %}">{{ organisation.pk|stringformat:"05d" }} | {{ organisation.name }} <span class="badge" title="{{count}} events with {{object.name}} for {{organisation.name}}">{{count}}</span></a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<h4>Events</h4>
|
||||
{% with object.latest_events as events %}
|
||||
{% include 'RIGS/event_table.html' %}
|
||||
{% endwith %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Associated Events</div>
|
||||
<div class="panel-body">
|
||||
{% with object.latest_events as events %}
|
||||
{% include 'RIGS/event_table.html' %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% if not request.is_ajax %}
|
||||
<div class="row">
|
||||
<div class="col-sm-12 text-right">
|
||||
<div class="btn-group btn-page">
|
||||
<a href="{% url 'person_update' object.pk %}" class="btn btn-default"><span
|
||||
class="glyphicon glyphicon-pencil"></span> Edit</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="{% url 'person_history' object.pk %}" title="View Revision History">
|
||||
Last edited {{ object.last_edited_at }} by {{ object.last_edited_by.name }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% if request.is_ajax %}
|
||||
{% block footer %}
|
||||
<div class="row">
|
||||
<div class="col-sm-10 align-left">
|
||||
<a href="{% url 'person_history' object.pk %}" title="View Revision History">
|
||||
Last edited at {{ object.last_edited_at|date:"d/m/Y H:i" }} by {{ object.last_edited_by.name }}
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<div class="pull-right">
|
||||
<a href="{% url 'person_update' object.pk %}" class="btn btn-primary">Edit <span
|
||||
class="glyphicon glyphicon-pencil"></span></a>
|
||||
<div class="col-sm-12 text-right">
|
||||
<div class="btn-group btn-page">
|
||||
<a href="{% url 'person_detail' object.pk %}" class="btn btn-default"><span
|
||||
class="glyphicon glyphicon-eye-open"></span> Open Page</a>
|
||||
<a href="{% url 'person_update' object.pk %}" class="btn btn-default"><span
|
||||
class="glyphicon glyphicon-pencil"></span> Edit</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="{% url 'person_history' object.pk %}" title="View Revision History">
|
||||
Last edited {{ object.last_edited_at }} by {{ object.last_edited_by.name }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,64 +1,96 @@
|
||||
{% extends request.is_ajax|yesno:"base_ajax.html,base.html" %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block title %}{{ object.name }}{% endblock %}
|
||||
{% block title %}Venue | {{ object.name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-sm-10 col-sm-offset-1">
|
||||
{% if not request.is_ajax %}
|
||||
<h3>{{ object.name }}<br/>
|
||||
<span class="small"><a href="{% url 'venue_history' object.pk %}" title="View Revision History">
|
||||
Last edited at {{ object.last_edited_at|date:"d/m/Y H:i" }} by {{ object.last_edited_by.name }}
|
||||
</a></span>
|
||||
</h3>
|
||||
<div class="pull-right">
|
||||
<a href="{% url 'venue_update' object.pk %}" class="btn btn-primary">Edit <span
|
||||
class="glyphicon glyphicon-pencil"></span></a>
|
||||
{% if not request.is_ajax %}
|
||||
<div class="col-sm-12">
|
||||
<h1>Venue | {{ object.name }}</h1>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 text-right">
|
||||
<div class="btn-group btn-page">
|
||||
<a href="{% url 'venue_update' object.pk %}" class="btn btn-default"><span
|
||||
class="glyphicon glyphicon-pencil"></span> Edit</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="">
|
||||
<dl class="dl-horizontal">
|
||||
<dt>Name</dt>
|
||||
<dd>{{ object.name }}</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="col-sm-12">
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading">Venue Details</div>
|
||||
<div class="panel-body">
|
||||
<dl class="dl-horizontal">
|
||||
<dt>Name</dt>
|
||||
<dd>{{ object.name }}</dd>
|
||||
|
||||
<dt>Phone</dt>
|
||||
<dd><a href="tel:{{ object.phone }}">{{ object.phone }}</a></dd>
|
||||
<dt>Phone</dt>
|
||||
<dd><a href="tel:{{ object.phone }}">{{ object.phone }}</a></dd>
|
||||
|
||||
<dt>Email</dt>
|
||||
<dd><a href="mailto:{{ object.email }}">{{ object.email }}</a></dd>
|
||||
<dt>Email</dt>
|
||||
<dd><a href="mailto:{{ object.email }}"><span class="overflow-ellipsis">{{ object.email }}</span></a></dd>
|
||||
|
||||
<dt>Address</dt>
|
||||
<dd>{{ object.address|linebreaksbr }}</dd>
|
||||
<dt>Address</dt>
|
||||
<dd>{{ object.address|linebreaksbr }}</dd>
|
||||
|
||||
<dt>Notes</dt>
|
||||
<dd>{{ object.notes|linebreaksbr }}</dd>
|
||||
</dl>
|
||||
<dt>Notes</dt>
|
||||
<dd>{{ object.notes|linebreaksbr }}</dd>
|
||||
|
||||
<dt>Three Phase Available</dt>
|
||||
<dd>{{ object.three_phase_available|yesno|capfirst }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
{% with object.latest_events as events %}
|
||||
{% include 'RIGS/event_table.html' %}
|
||||
{% endwith %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Associated Events</div>
|
||||
<div class="panel-body">
|
||||
{% with object.latest_events as events %}
|
||||
{% include 'RIGS/event_table.html' %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if not request.is_ajax %}
|
||||
<div class="row">
|
||||
<div class="col-sm-12 text-right">
|
||||
<div class="btn-group btn-page">
|
||||
<a href="{% url 'venue_update' object.pk %}" class="btn btn-default"><span
|
||||
class="glyphicon glyphicon-pencil"></span> Edit</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="{% url 'venue_history' object.pk %}" title="View Revision History">
|
||||
Last edited {{ object.last_edited_at }} by {{ object.last_edited_by.name }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% if request.is_ajax %}
|
||||
{% block footer %}
|
||||
<div class="row">
|
||||
<div class="col-sm-10 align-left">
|
||||
<a href="{% url 'venue_history' object.pk %}" title="View Revision History">
|
||||
Last edited at {{ object.last_edited_at|date:"d/m/Y H:i" }} by {{ object.last_edited_by.name }}
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<div class="pull-right">
|
||||
<a href="{% url 'venue_update' object.pk %}" class="btn btn-primary">Edit <span
|
||||
class="glyphicon glyphicon-pencil"></span></a>
|
||||
<div class="col-sm-12 text-right">
|
||||
<div class="btn-group btn-page">
|
||||
<a href="{% url 'venue_detail' object.pk %}" class="btn btn-default"><span
|
||||
class="glyphicon glyphicon-eye-open"></span> Open Page</a>
|
||||
<a href="{% url 'venue_update' object.pk %}" class="btn btn-default"><span
|
||||
class="glyphicon glyphicon-pencil"></span> Edit</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="{% url 'venue_history' object.pk %}" title="View Revision History">
|
||||
Last edited {{ object.last_edited_at }} by {{ object.last_edited_by.name }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -58,7 +58,21 @@
|
||||
{% render_field form.notes class+="form-control" placeholder=form.notes.label %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-10 col-sm-offset-2">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
{% render_field form.three_phase_available %} {{ form.three_phase_available.label }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="btn btn-primary pull-right" type="submit"/>
|
||||
|
||||
@@ -143,6 +143,8 @@ class EventTest(LiveServerTestCase):
|
||||
self.profile.set_password("EventTestPassword")
|
||||
self.profile.save()
|
||||
|
||||
self.vatrate = models.VatRate.objects.create(start_at='2014-03-05',rate=0.20,comment='test1')
|
||||
|
||||
self.browser = webdriver.Firefox()
|
||||
os.environ['RECAPTCHA_TESTING'] = 'True'
|
||||
|
||||
@@ -375,9 +377,9 @@ class EventTest(LiveServerTestCase):
|
||||
|
||||
# Check totals
|
||||
self.assertEqual("47.90", self.browser.find_element_by_id('sumtotal').text)
|
||||
self.assertIn("TBD%", self.browser.find_element_by_id('vat-rate').text)
|
||||
self.assertEqual("0.00", self.browser.find_element_by_id('vat').text)
|
||||
self.assertEqual("47.90", self.browser.find_element_by_id('total').text)
|
||||
self.assertIn("(TBC)", self.browser.find_element_by_id('vat-rate').text)
|
||||
self.assertEqual("9.58", self.browser.find_element_by_id('vat').text)
|
||||
self.assertEqual("57.48", self.browser.find_element_by_id('total').text)
|
||||
|
||||
# Attempt to save - missing title
|
||||
save.click()
|
||||
@@ -412,6 +414,121 @@ class EventTest(LiveServerTestCase):
|
||||
event = models.Event.objects.get(name='Test Event Name')
|
||||
self.assertIn("N0000%d | Test Event Name"%event.pk, self.browser.find_element_by_xpath('//h1').text)
|
||||
|
||||
def testDateValidation(self):
|
||||
self.browser.get(self.live_server_url + '/event/create/')
|
||||
# Gets redirected to login and back
|
||||
self.authenticate('/event/create/')
|
||||
|
||||
wait = WebDriverWait(self.browser, 10) #setup WebDriverWait to use later (to wait for animations)
|
||||
self.browser.implicitly_wait(3) #Set session-long wait (only works for non-existant DOM objects)
|
||||
|
||||
wait.until(animation_is_finished())
|
||||
|
||||
# Click Rig button
|
||||
self.browser.find_element_by_xpath('//button[.="Rig"]').click()
|
||||
|
||||
form = self.browser.find_element_by_tag_name('form')
|
||||
save = self.browser.find_element_by_xpath('(//button[@type="submit"])[3]')
|
||||
|
||||
# Set title
|
||||
e = self.browser.find_element_by_id('id_name')
|
||||
e.send_keys('Test Event Name')
|
||||
|
||||
# Both dates, no times, end before start
|
||||
form.find_element_by_id('id_start_date').clear()
|
||||
form.find_element_by_id('id_start_date').send_keys('3015-04-24')
|
||||
|
||||
form.find_element_by_id('id_end_date').clear()
|
||||
form.find_element_by_id('id_end_date').send_keys('3015-04-23')
|
||||
|
||||
# Attempt to save - should fail
|
||||
save.click()
|
||||
error = self.browser.find_element_by_xpath('//div[contains(@class, "alert-danger")]')
|
||||
self.assertTrue(error.is_displayed())
|
||||
self.assertIn("can't finish before it has started", error.find_element_by_xpath('//dd[1]/ul/li').text)
|
||||
|
||||
|
||||
# Same date, end time before start time
|
||||
form = self.browser.find_element_by_tag_name('form')
|
||||
save = self.browser.find_element_by_xpath('(//button[@type="submit"])[3]')
|
||||
form.find_element_by_id('id_start_date').clear()
|
||||
form.find_element_by_id('id_start_date').send_keys('3015-04-24')
|
||||
|
||||
form.find_element_by_id('id_end_date').clear()
|
||||
form.find_element_by_id('id_end_date').send_keys('3015-04-23')
|
||||
|
||||
form.find_element_by_id('id_start_time').clear()
|
||||
form.find_element_by_id('id_start_time').send_keys('06:59')
|
||||
|
||||
form.find_element_by_id('id_end_time').clear()
|
||||
form.find_element_by_id('id_end_time').send_keys('06:00')
|
||||
|
||||
# Attempt to save - should fail
|
||||
save.click()
|
||||
error = self.browser.find_element_by_xpath('//div[contains(@class, "alert-danger")]')
|
||||
self.assertTrue(error.is_displayed())
|
||||
self.assertIn("can't finish before it has started", error.find_element_by_xpath('//dd[1]/ul/li').text)
|
||||
|
||||
|
||||
# Same date, end time before start time
|
||||
form = self.browser.find_element_by_tag_name('form')
|
||||
save = self.browser.find_element_by_xpath('(//button[@type="submit"])[3]')
|
||||
form.find_element_by_id('id_start_date').clear()
|
||||
form.find_element_by_id('id_start_date').send_keys('3015-04-24')
|
||||
|
||||
form.find_element_by_id('id_end_date').clear()
|
||||
form.find_element_by_id('id_end_date').send_keys('3015-04-23')
|
||||
|
||||
form.find_element_by_id('id_start_time').clear()
|
||||
form.find_element_by_id('id_start_time').send_keys('06:59')
|
||||
|
||||
form.find_element_by_id('id_end_time').clear()
|
||||
form.find_element_by_id('id_end_time').send_keys('06:00')
|
||||
|
||||
|
||||
# No end date, end time before start time
|
||||
form = self.browser.find_element_by_tag_name('form')
|
||||
save = self.browser.find_element_by_xpath('(//button[@type="submit"])[3]')
|
||||
form.find_element_by_id('id_start_date').clear()
|
||||
form.find_element_by_id('id_start_date').send_keys('3015-04-24')
|
||||
|
||||
form.find_element_by_id('id_end_date').clear()
|
||||
|
||||
form.find_element_by_id('id_start_time').clear()
|
||||
form.find_element_by_id('id_start_time').send_keys('06:59')
|
||||
|
||||
form.find_element_by_id('id_end_time').clear()
|
||||
form.find_element_by_id('id_end_time').send_keys('06:00')
|
||||
|
||||
# Attempt to save - should fail
|
||||
save.click()
|
||||
error = self.browser.find_element_by_xpath('//div[contains(@class, "alert-danger")]')
|
||||
self.assertTrue(error.is_displayed())
|
||||
self.assertIn("can't finish before it has started", error.find_element_by_xpath('//dd[1]/ul/li').text)
|
||||
|
||||
|
||||
# 2 dates, end after start
|
||||
form = self.browser.find_element_by_tag_name('form')
|
||||
save = self.browser.find_element_by_xpath('(//button[@type="submit"])[3]')
|
||||
form.find_element_by_id('id_start_date').clear()
|
||||
form.find_element_by_id('id_start_date').send_keys('3015-04-24')
|
||||
|
||||
form.find_element_by_id('id_end_date').clear()
|
||||
form.find_element_by_id('id_end_date').send_keys('3015-04-26')
|
||||
|
||||
form.find_element_by_id('id_start_time').clear()
|
||||
|
||||
form.find_element_by_id('id_end_time').clear()
|
||||
|
||||
# Attempt to save - should succeed
|
||||
save.click()
|
||||
|
||||
# See redirected to success page
|
||||
event = models.Event.objects.get(name='Test Event Name')
|
||||
self.assertIn("N0000%d | Test Event Name"%event.pk, self.browser.find_element_by_xpath('//h1').text)
|
||||
|
||||
|
||||
|
||||
def testEventDetail(self):
|
||||
with transaction.atomic(), reversion.create_revision():
|
||||
person = models.Person(name="Event Detail Person", email="eventdetail@person.tests.rigs", phone="123 123")
|
||||
|
||||
@@ -144,16 +144,16 @@ class EventTestCase(TestCase):
|
||||
events = models.Event.objects.all()
|
||||
|
||||
# Check person's organisations
|
||||
self.assertIn(o1, p1.organisations)
|
||||
self.assertIn(o2, p1.organisations)
|
||||
self.assertIn(o1, p2.organisations)
|
||||
self.assertNotIn(o2, p2.organisations)
|
||||
self.assertIn((o1,2), p1.organisations)
|
||||
self.assertIn((o2,1), p1.organisations)
|
||||
self.assertIn((o1,2), p2.organisations)
|
||||
self.assertEqual(len(p2.organisations), 1)
|
||||
|
||||
# Check organisation's persons
|
||||
self.assertIn(p1, o1.persons)
|
||||
self.assertIn(p2, o1.persons)
|
||||
self.assertIn(p1, o2.persons)
|
||||
self.assertNotIn(p2, o2.persons)
|
||||
self.assertIn((p1,2), o1.persons)
|
||||
self.assertIn((p2,2), o1.persons)
|
||||
self.assertIn((p1,1), o2.persons)
|
||||
self.assertEqual(len(o2.persons),1)
|
||||
|
||||
def test_cancelled_property(self):
|
||||
event = models.Event.objects.all()[0]
|
||||
|
||||
@@ -176,7 +176,7 @@ class VenueDetail(generic.DetailView):
|
||||
|
||||
class VenueCreate(generic.CreateView):
|
||||
model = models.Venue
|
||||
fields = ['name','phone','email','address','notes']
|
||||
fields = ['name','phone','email','address','notes','three_phase_available']
|
||||
|
||||
def get_success_url(self):
|
||||
if self.request.is_ajax():
|
||||
@@ -193,7 +193,7 @@ class VenueCreate(generic.CreateView):
|
||||
|
||||
class VenueUpdate(generic.UpdateView):
|
||||
model = models.Venue
|
||||
fields = ['name','phone','email','address','notes']
|
||||
fields = ['name','phone','email','address','notes','three_phase_available']
|
||||
|
||||
def get_success_url(self):
|
||||
if self.request.is_ajax():
|
||||
|
||||
133
Vagrantfile
vendored
Normal file
133
Vagrantfile
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
require 'yaml'
|
||||
|
||||
unless File.exist?('config/vagrant.yml')
|
||||
raise "There is no config/vagrant.yml file.\nCopy config/vagrant.template.yml, make any changes you need, then try again."
|
||||
end
|
||||
|
||||
settings = YAML.load_file 'config/vagrant.yml'
|
||||
|
||||
$script = <<SCRIPT
|
||||
echo Beginning Vagrant provisioning...
|
||||
date > /etc/vagrant_provisioned_at
|
||||
SCRIPT
|
||||
|
||||
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
||||
VAGRANTFILE_API_VERSION = '2'
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
# The most common configuration options are documented and commented below.
|
||||
# For a complete reference, please see the online documentation at
|
||||
# https://docs.vagrantup.com.
|
||||
|
||||
config.vm.provision 'shell', inline: $script
|
||||
|
||||
# Every Vagrant development environment requires a box. You can search for
|
||||
# boxes at https://atlas.hashicorp.com/search.
|
||||
config.vm.box = 'ubuntu/trusty64'
|
||||
|
||||
# Share an additional folder to the guest VM. The first argument is
|
||||
# the path on the host to the actual folder. The second argument is
|
||||
# the path on the guest to mount the folder. And the optional third
|
||||
# argument is a set of non-required options.
|
||||
config.vm.synced_folder ".", "/vagrant"
|
||||
|
||||
# Create a forwarded port mapping which allows access to a specific port
|
||||
# within the machine from a port on the host machine. In the example below,
|
||||
# accessing "localhost:5000" will access port 5000 on the guest machine.
|
||||
config.vm.network "forwarded_port", guest: 5000, host: 5000
|
||||
|
||||
# PostgreSQL Server port forwarding
|
||||
config.vm.network "forwarded_port", host: 15432, guest: 5432
|
||||
|
||||
# You can provision with just one of these scripts by user its name, eg:
|
||||
# $ vagrant provision --provision-with postgresql
|
||||
|
||||
config.vm.provision 'build',
|
||||
type: 'shell',
|
||||
path: 'config/vagrant/build_dependency_setup.sh'
|
||||
|
||||
config.vm.provision 'git',
|
||||
type: 'shell',
|
||||
path: 'config/vagrant/git_setup.sh'
|
||||
|
||||
config.vm.provision 'postgresql',
|
||||
type: 'shell',
|
||||
path: 'config/vagrant/postgresql_setup.sh',
|
||||
args: [
|
||||
settings['db']['name'],
|
||||
settings['db']['user'],
|
||||
settings['db']['password'],
|
||||
]
|
||||
|
||||
config.vm.provision 'python',
|
||||
type: 'shell',
|
||||
path: 'config/vagrant/python_setup.sh'
|
||||
|
||||
config.vm.provision 'virtualenv',
|
||||
type: 'shell',
|
||||
path: 'config/vagrant/virtualenv_setup.sh',
|
||||
args: [
|
||||
settings['virtualenv']['envname'],
|
||||
]
|
||||
|
||||
# Will install foreman and, if there's a Procfile, start it:
|
||||
config.vm.provision 'foreman',
|
||||
type: 'shell',
|
||||
path: 'config/vagrant/foreman_setup.sh',
|
||||
args: [
|
||||
settings['virtualenv']['envname'],
|
||||
settings['django']['settings_module'],
|
||||
settings['foreman']['procfile'],
|
||||
]
|
||||
|
||||
# Disable automatic box update checking. If you disable this, then
|
||||
# boxes will only be checked for updates when the user runs
|
||||
# `vagrant box outdated`. This is not recommended.
|
||||
# config.vm.box_check_update = false
|
||||
|
||||
# Create a forwarded port mapping which allows access to a specific port
|
||||
# within the machine from a port on the host machine. In the example below,
|
||||
# accessing "localhost:8080" will access port 80 on the guest machine.
|
||||
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
||||
|
||||
# Create a private network, which allows host-only access to the machine
|
||||
# using a specific IP.
|
||||
# config.vm.network "private_network", ip: "192.168.33.10"
|
||||
|
||||
# Create a public network, which generally matched to bridged network.
|
||||
# Bridged networks make the machine appear as another physical device on
|
||||
# your network.
|
||||
# config.vm.network "public_network"
|
||||
|
||||
# Provider-specific configuration so you can fine-tune various
|
||||
# backing providers for Vagrant. These expose provider-specific options.
|
||||
# Example for VirtualBox:
|
||||
#
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
# # Display the VirtualBox GUI when booting the machine
|
||||
# vb.gui = true
|
||||
#
|
||||
# # Customize the amount of memory on the VM:
|
||||
vb.memory = "1024"
|
||||
end
|
||||
#
|
||||
# View the documentation for the provider you are using for more
|
||||
# information on available options.
|
||||
|
||||
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
|
||||
# such as FTP and Heroku are also available. See the documentation at
|
||||
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
|
||||
# config.push.define "atlas" do |push|
|
||||
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
|
||||
# end
|
||||
|
||||
# Enable provisioning with a shell script. Additional provisioners such as
|
||||
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
|
||||
# documentation for more information about their specific syntax and use.
|
||||
# config.vm.provision "shell", inline: <<-SHELL
|
||||
# sudo apt-get update
|
||||
# sudo apt-get install -y apache2
|
||||
# SHELL
|
||||
end
|
||||
11
config/vagrant.yml
Normal file
11
config/vagrant.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
django:
|
||||
settings_module: PyRIGS.settings
|
||||
virtualenv:
|
||||
envname: myvirtualenv
|
||||
foreman:
|
||||
procfile: Procfile
|
||||
db:
|
||||
name: postgres_db
|
||||
user: postgres_db
|
||||
password: postgres_db
|
||||
|
||||
16
config/vagrant/build_dependency_setup.sh
Normal file
16
config/vagrant/build_dependency_setup.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Via https://github.com/kiere/vagrant-heroku-cedar-14/blob/master/config/vagrant/build_dependency_setup.sh
|
||||
|
||||
echo "=== Begin Vagrant Provisioning using 'config/vagrant/build_dependency_setup.sh'"
|
||||
|
||||
# Install build dependencies for a sane build environment
|
||||
apt-get -y update
|
||||
apt-get -y install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
|
||||
|
||||
# Other things that we may need installed before anything else.
|
||||
apt-get install -y libmemcached-dev
|
||||
apt-get build-dep python-lxml
|
||||
|
||||
echo "=== End Vagrant Provisioning using 'config/vagrant/build_dependency_setup.sh'"
|
||||
|
||||
36
config/vagrant/foreman_setup.sh
Normal file
36
config/vagrant/foreman_setup.sh
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Install and (if there's a Procfile) start foreman.
|
||||
# Needs to come after the virtualenv has been set up.
|
||||
|
||||
# Expects three arguments:
|
||||
VIRTUALENV_NAME=$1
|
||||
DJANGO_SETTINGS_MODULE=$2
|
||||
PROCFILE=$3
|
||||
|
||||
echo "=== Begin Vagrant Provisioning using 'config/vagrant/foreman_setup.sh'"
|
||||
|
||||
gem install foreman --no-ri --no-rdoc
|
||||
|
||||
if ! grep -Fq "DJANGO_SETTINGS_MODULE" /home/vagrant/.bashrc; then
|
||||
echo "export DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE}" >> /home/vagrant/.bashrc
|
||||
fi
|
||||
|
||||
|
||||
if [[ -f /vagrant/$PROCFILE ]]; then
|
||||
echo "Procfile found; starting foreman."
|
||||
|
||||
export DJANGO_SETTINGS_MODULE="$DJANGO_SETTINGS_MODULE"
|
||||
|
||||
# Ensure the virtualenv settings in .profile are loaded:
|
||||
source /home/vagrant/.profile
|
||||
|
||||
# Run with & to release the terminal.
|
||||
# Although that may also rely on the Procfile's processes having their
|
||||
# output sent to a file, not stdout/stderr.
|
||||
foreman start -f /vagrant/$PROCFILE &
|
||||
else
|
||||
echo "No Procfile found; not starting foreman."
|
||||
fi
|
||||
|
||||
echo "=== End Vagrant Provisioning using 'config/vagrant/foreman_setup.sh'"
|
||||
14
config/vagrant/git_setup.sh
Normal file
14
config/vagrant/git_setup.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Via https://github.com/kiere/vagrant-heroku-cedar-14/blob/master/config/vagrant/git_setup.sh
|
||||
|
||||
echo "=== Begin Vagrant Provisioning using 'config/vagrant/git_setup.sh'"
|
||||
|
||||
# Install Git if not available
|
||||
if [ -z `which git` ]; then
|
||||
echo "===== Installing Git"
|
||||
apt-get -y update
|
||||
apt-get -y install git-core
|
||||
fi
|
||||
|
||||
echo "=== End Vagrant Provisioning using 'config/vagrant/git_setup.sh'"
|
||||
112
config/vagrant/postgresql_setup.sh
Normal file
112
config/vagrant/postgresql_setup.sh
Normal file
@@ -0,0 +1,112 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
# Expects three arguments:
|
||||
# $1 - database name
|
||||
# $2 - database user
|
||||
# #3 - database user password
|
||||
|
||||
# Via https://github.com/kiere/vagrant-heroku-cedar-14/blob/master/config/vagrant/postgresql_setup.sh
|
||||
|
||||
echo "=== Begin Vagrant Provisioning using 'config/vagrant/postgresql_setup.sh'"
|
||||
|
||||
APP_DB_NAME=$1
|
||||
APP_DB_USER=$2
|
||||
APP_DB_PASS=$3
|
||||
|
||||
# Edit the following to change the version of PostgreSQL that is installed
|
||||
PG_VERSION=9.4
|
||||
|
||||
###########################################################
|
||||
# Changes below this line are probably not necessary
|
||||
###########################################################
|
||||
print_db_usage () {
|
||||
echo "Your PostgreSQL database has been setup and can be accessed on your local machine on the forwarded port (default: 15432)"
|
||||
echo " Host: localhost"
|
||||
echo " Port: 15432"
|
||||
echo " Database: $APP_DB_NAME"
|
||||
echo " Username: $APP_DB_USER"
|
||||
echo " Password: $APP_DB_PASS"
|
||||
echo ""
|
||||
echo "Admin access to postgres user via VM:"
|
||||
echo " vagrant ssh"
|
||||
echo " sudo su - postgres"
|
||||
echo ""
|
||||
echo "psql access to app database user via VM:"
|
||||
echo " vagrant ssh"
|
||||
echo " sudo su - postgres"
|
||||
echo " PGUSER=$APP_DB_USER PGPASSWORD=$APP_DB_PASS psql -h localhost $APP_DB_NAME"
|
||||
echo ""
|
||||
echo "Env variable for application development:"
|
||||
echo " DATABASE_URL=postgresql://$APP_DB_USER:$APP_DB_PASS@localhost:15432/$APP_DB_NAME"
|
||||
echo ""
|
||||
echo "Local command to access the database via psql:"
|
||||
echo " PGUSER=$APP_DB_USER PGPASSWORD=$APP_DB_PASS psql -h localhost -p 15432 $APP_DB_NAME"
|
||||
}
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
PROVISIONED_ON=/etc/vm_provision_on_timestamp
|
||||
if [ -f "$PROVISIONED_ON" ]
|
||||
then
|
||||
echo "VM was already provisioned at: $(cat $PROVISIONED_ON)"
|
||||
echo "To run system updates manually login via 'vagrant ssh' and run 'apt-get update && apt-get upgrade'"
|
||||
echo ""
|
||||
print_db_usage
|
||||
exit
|
||||
fi
|
||||
|
||||
PG_REPO_APT_SOURCE=/etc/apt/sources.list.d/pgdg.list
|
||||
if [ ! -f "$PG_REPO_APT_SOURCE" ]
|
||||
then
|
||||
# Add PG apt repo:
|
||||
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > "$PG_REPO_APT_SOURCE"
|
||||
|
||||
# Add PGDG repo key:
|
||||
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add -
|
||||
fi
|
||||
|
||||
# Update package list and upgrade all packages
|
||||
apt-get update
|
||||
apt-get -y upgrade
|
||||
|
||||
apt-get -y install "postgresql-$PG_VERSION" "postgresql-contrib-$PG_VERSION"
|
||||
apt-get -y install libpq-dev # For building ruby 'pg' gem
|
||||
|
||||
PG_CONF="/etc/postgresql/$PG_VERSION/main/postgresql.conf"
|
||||
PG_HBA="/etc/postgresql/$PG_VERSION/main/pg_hba.conf"
|
||||
PG_DIR="/var/lib/postgresql/$PG_VERSION/main"
|
||||
|
||||
# Edit postgresql.conf to change listen address to '*':
|
||||
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" "$PG_CONF"
|
||||
|
||||
# Append to pg_hba.conf to add password auth:
|
||||
echo "host all all all md5" >> "$PG_HBA"
|
||||
|
||||
# Explicitly set default client_encoding
|
||||
echo "client_encoding = utf8" >> "$PG_CONF"
|
||||
|
||||
# Restart so that all new config is loaded:
|
||||
service postgresql restart
|
||||
|
||||
cat << EOF | su - postgres -c psql
|
||||
-- Create the database user:
|
||||
CREATE USER $APP_DB_USER PASSWORD '$APP_DB_PASS';
|
||||
EOF
|
||||
|
||||
cat << EOF | su - postgres -c psql
|
||||
-- Create the database:
|
||||
CREATE DATABASE $APP_DB_NAME WITH OWNER=$APP_DB_USER
|
||||
LC_COLLATE='en_US.utf8'
|
||||
LC_CTYPE='en_US.utf8'
|
||||
ENCODING='UTF8'
|
||||
TEMPLATE=template0;
|
||||
EOF
|
||||
|
||||
# Tag the provision time:
|
||||
date > "$PROVISIONED_ON"
|
||||
|
||||
echo "Successfully created PostgreSQL dev virtual machine."
|
||||
echo ""
|
||||
print_db_usage
|
||||
|
||||
echo "=== End Vagrant Provisioning using 'config/vagrant/postgresql_setup.sh'"
|
||||
23
config/vagrant/python_setup.sh
Normal file
23
config/vagrant/python_setup.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Install python and required python modules.
|
||||
# pip and virtualenv are in virtualenv_setup.sh
|
||||
|
||||
# Initial part of this via
|
||||
# https://github.com/torchbox/vagrant-django-base/blob/master/install.sh
|
||||
|
||||
echo "=== Begin Vagrant Provisioning using 'config/vagrant/python_setup.sh'"
|
||||
|
||||
apt-get update -y
|
||||
|
||||
# Python dev packages
|
||||
apt-get install -y python python-dev python-setuptools python-pip
|
||||
|
||||
# Dependencies for image processing with Pillow (drop-in replacement for PIL)
|
||||
# supporting: jpeg, tiff, png, freetype, littlecms
|
||||
apt-get install -y libjpeg-dev libtiff-dev zlib1g-dev libfreetype6-dev liblcms2-dev
|
||||
|
||||
# lxml dependencies
|
||||
apt-get install -y libxml2-dev libxslt1-dev python-dev
|
||||
|
||||
echo "=== End Vagrant Provisioning using 'config/vagrant/python_setup.sh'"
|
||||
66
config/vagrant/virtualenv_setup.sh
Normal file
66
config/vagrant/virtualenv_setup.sh
Normal file
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This will:
|
||||
# * Install pip, virtualenv and virtualenvwrapper.
|
||||
# * Set up virtualenvwrapper's paths etc.
|
||||
# * Create a new virtualenv.
|
||||
# * Install any pip requirements from the requirements.txt file.
|
||||
|
||||
# Expects one argument, the name of the virtualenv.
|
||||
|
||||
# The name we'll use for the virtualenv in which we'll install requirements:
|
||||
VENV_NAME=$1
|
||||
|
||||
echo "=== Begin Vagrant Provisioning using 'config/vagrant/virtualenv_setup.sh'"
|
||||
|
||||
# virtualenv global setup
|
||||
if ! command -v pip; then
|
||||
easy_install -U pip
|
||||
fi
|
||||
|
||||
if [[ ! -f /usr/local/bin/virtualenv ]]; then
|
||||
easy_install virtualenv virtualenvwrapper
|
||||
fi
|
||||
|
||||
|
||||
# If it doesn't look like .bashrc has the required virtualenvwrapper lines in,
|
||||
# then add them.
|
||||
if ! grep -Fq "WORKON_HOME" /home/vagrant/.profile; then
|
||||
echo "Adding virtualenvwrapper locations to .profile"
|
||||
|
||||
if [[ -d /vagrant/config/virtualenvwrapper/vagrant ]]; then
|
||||
echo "export VIRTUALENVWRAPPER_HOOK_DIR=/vagrant/config/virtualenvwrapper/vagrant" >> /home/vagrant/.profile
|
||||
fi
|
||||
|
||||
echo "export WORKON_HOME=/home/vagrant/.virtualenvs" >> /home/vagrant/.profile
|
||||
echo "export PROJECT_HOME=/home/vagrant/Devel" >> /home/vagrant/.profile
|
||||
echo "source /usr/local/bin/virtualenvwrapper.sh" >> /home/vagrant/.profile
|
||||
fi
|
||||
|
||||
# Get .virtualenvwrapper env variables set up:
|
||||
source /home/vagrant/.profile
|
||||
|
||||
if [[ -d /home/vagrant/.virtualenvs/$VENV_NAME ]]; then
|
||||
echo "Activating virtualenv $VENV_NAME."
|
||||
workon $VENV_NAME
|
||||
else
|
||||
echo "Making new virtualenv $VENV_NAME."
|
||||
# Also switches to the virtualenv:
|
||||
mkvirtualenv $VENV_NAME
|
||||
|
||||
# So that we can install things with pip while ssh'd in as vagrant user:
|
||||
sudo chown -R vagrant:vagrant /home/vagrant/.virtualenvs/$VENV_NAME/
|
||||
|
||||
# Automatically switch to the virtual env on log in:
|
||||
echo "workon $VENV_NAME" >> /home/vagrant/.profile
|
||||
fi
|
||||
|
||||
|
||||
# If we have a requirements.txt file in this project, then install
|
||||
# everything in it with pip in a new virtualenv.
|
||||
if [[ -f /vagrant/requirements.txt ]]; then
|
||||
echo "Installing from ./requirements.txt with pip."
|
||||
pip install -r /vagrant/requirements.txt
|
||||
fi
|
||||
|
||||
echo "=== End Vagrant Provisioning using 'config/vagrant/virtualenv_setup.sh'"
|
||||
Reference in New Issue
Block a user