diff --git a/.gitignore b/.gitignore index 064616b6..9a6f7595 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file +crashlytics-build.properties +.vagrant diff --git a/RIGS/models.py b/RIGS/models.py index 4a86d9df..268f8eeb 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -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'), diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index 9853d9d0..27f00307 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -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()): diff --git a/RIGS/static/imgs/paperwork/corner-bl.jpg b/RIGS/static/imgs/paperwork/corner-bl.jpg new file mode 100644 index 00000000..d31070f3 Binary files /dev/null and b/RIGS/static/imgs/paperwork/corner-bl.jpg differ diff --git a/RIGS/static/imgs/paperwork/corner.jpg b/RIGS/static/imgs/paperwork/corner-tr-su.jpg similarity index 100% rename from RIGS/static/imgs/paperwork/corner.jpg rename to RIGS/static/imgs/paperwork/corner-tr-su.jpg diff --git a/RIGS/static/imgs/paperwork/corner-tr.jpg b/RIGS/static/imgs/paperwork/corner-tr.jpg new file mode 100644 index 00000000..02a6fddd Binary files /dev/null and b/RIGS/static/imgs/paperwork/corner-tr.jpg differ diff --git a/RIGS/templates/RIGS/event_print.xml b/RIGS/templates/RIGS/event_print.xml index bf5f798f..152886e0 100644 --- a/RIGS/templates/RIGS/event_print.xml +++ b/RIGS/templates/RIGS/event_print.xml @@ -82,7 +82,8 @@