From 6944d98c4eb35b67ab20e701fa27c9a6a02b13b2 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 29 Jul 2015 22:06:44 +0100 Subject: [PATCH 1/7] Added paperwork generation date, user & versioning --- RIGS/finance.py | 1 + RIGS/models.py | 9 +++++++++ RIGS/rigboard.py | 3 ++- RIGS/templates/RIGS/event_print.xml | 4 ++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/RIGS/finance.py b/RIGS/finance.py index 2ae0fc47..73552f2e 100644 --- a/RIGS/finance.py +++ b/RIGS/finance.py @@ -55,6 +55,7 @@ class InvoicePrint(generic.View): } }, 'invoice':invoice, + 'current_user':request.user, }) rml = template.render(context) diff --git a/RIGS/models.py b/RIGS/models.py index 49963a6f..636c7dca 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -71,6 +71,15 @@ class RevisionMixin(object): else: return None + @property + def current_version_id(self): + versions = reversion.get_for_object(self) + if versions: + version = reversion.get_for_object(self)[0] + return "V{0} | R{1}".format(version.pk,version.revision.pk) + else: + return None + @reversion.register @python_2_unicode_compatible class Person(models.Model, RevisionMixin): diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index 27f00307..b13a19c8 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -104,7 +104,8 @@ class EventPrint(generic.View): 'bold': 'RIGS/static/fonts/OPENSANS-BOLD.TTF', } }, - 'copy':copy + 'copy':copy, + 'current_user':request.user, }) # context['copy'] = copy # this is the way to do it once we upgrade to Django 1.8.3 diff --git a/RIGS/templates/RIGS/event_print.xml b/RIGS/templates/RIGS/event_print.xml index 152886e0..6d693117 100644 --- a/RIGS/templates/RIGS/event_print.xml +++ b/RIGS/templates/RIGS/event_print.xml @@ -102,6 +102,8 @@ {% if not invoice %}[{{ copy }} Copy]{% endif %} [Page of ] + + [Paperwork generated by {{current_user.name}} | {% now "d/m/Y H:i" %} | {{object.current_version_id}}] @@ -115,6 +117,8 @@ {% if not invoice %}[{{ copy }} Copy]{% endif %} [Page of ] + + [Paperwork generated by {{current_user.name}} | {% now "d/m/Y H:i" %} | {{object.current_version_id}}] From c36a90ba3770ff144ddd8d705af72075fe4cac86 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 16 Aug 2015 21:06:32 +0100 Subject: [PATCH 2/7] Added a day to end dates, if there is no end time (ical and fullcalendar.js use non-inclusive end dates). Issue #154 --- RIGS/ical.py | 3 +++ RIGS/templates/RIGS/calendar.html | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/RIGS/ical.py b/RIGS/ical.py index 8ae94342..47ee669e 100644 --- a/RIGS/ical.py +++ b/RIGS/ical.py @@ -97,6 +97,9 @@ class CalendarICS(ICalFeed): return item.earliest_time def item_end_datetime(self, item): + if type(item.latest_time) is datetime.date: # Ical end_datetime is non-inclusive, so add a day + return item.latest_time + datetime.timedelta(days=1) + return item.latest_time def item_location(self,item): diff --git a/RIGS/templates/RIGS/calendar.html b/RIGS/templates/RIGS/calendar.html index 0ac85749..23a0b1b8 100644 --- a/RIGS/templates/RIGS/calendar.html +++ b/RIGS/templates/RIGS/calendar.html @@ -56,11 +56,14 @@ 'non-rig': '#5bc0de' }; $(doc).each(function() { - + end = $(this).attr('latest') + if(end.indexOf("T") < 0){ //If latest does not contain a time + end = moment(end).add(1, 'days') //End date is non-inclusive, so add a day + } thisEvent = { 'start': $(this).attr('earliest'), - 'end': $(this).attr('latest'), + 'end': end, 'className': 'modal-href', 'title': $(this).attr('title'), 'url': $(this).attr('url') From 63cb5022dfff20737147d85f815e113af54fbaad Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 16 Aug 2015 23:24:02 +0100 Subject: [PATCH 3/7] Added helpful tooltips for each input field in event_form --- RIGS/templates/RIGS/event_form.html | 42 ++++++++++++++++------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/RIGS/templates/RIGS/event_form.html b/RIGS/templates/RIGS/event_form.html index cf627aa7..4d3c3509 100644 --- a/RIGS/templates/RIGS/event_form.html +++ b/RIGS/templates/RIGS/event_form.html @@ -19,6 +19,7 @@ + @@ -110,6 +111,9 @@ $(document).ready(function () { setupItemTable($("#{{ form.items_json.id_for_label }}").val()); }); + $(function () { + $('[data-toggle="tooltip"]').tooltip(); + }) {% endblock %} @@ -160,7 +164,7 @@
Contact Details
-
+
@@ -187,14 +191,14 @@
-
+
- {% if organisation %} {% endif %} @@ -219,7 +223,7 @@
Event Description
-
+
@@ -238,7 +242,7 @@
Event Details
-
+
@@ -246,7 +250,7 @@ {% render_field form.name class+="form-control" %}
-
+
@@ -279,10 +283,10 @@
-
+
{% render_field form.start_date type="date" class+="form-control" %}
-
+
{% render_field form.start_time type="time" class+="form-control" %}
@@ -294,10 +298,10 @@
-
+
{% render_field form.end_date type="date" class+="form-control" %}
-
+
{% render_field form.end_time type="time" class+="form-control" %}
@@ -315,7 +319,7 @@ {# Rig only information #}
-
+
@@ -323,7 +327,7 @@ {% render_field form.access_at type="datetime-local" class+="form-control" %}
-
+
@@ -334,7 +338,7 @@
-
@@ -343,7 +347,7 @@
{# Status is needed on all events types and it looks good here in the form #} -
+
@@ -353,7 +357,7 @@
-
+
@@ -367,7 +371,7 @@
{% if object.dry_hire %} -
+
@@ -381,7 +385,7 @@
{% endif %} -
+
@@ -389,7 +393,7 @@ {% render_field form.collector class+="form-control" %}
-
+
@@ -417,7 +421,7 @@
-
+
{% render_field form.notes class+="form-control" %}
From 0cf62f983f2d3aa2a9665caba5e67f2dbb2bacde Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 27 Aug 2015 01:35:27 +0100 Subject: [PATCH 4/7] Added data save check to registration (currently fails) --- RIGS/test_functional.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/RIGS/test_functional.py b/RIGS/test_functional.py index 514e030f..65f83252 100644 --- a/RIGS/test_functional.py +++ b/RIGS/test_functional.py @@ -134,6 +134,15 @@ class UserRegistrationTest(LiveServerTestCase): udd = self.browser.find_element_by_class_name('navbar').text self.assertIn('Hi John', udd) + # Check all the data actually got saved + profileObject = models.Profile.objects.all()[0] + self.assertEqual(profileObject.username, 'TestUsername') + self.assertEqual(profileObject.first_name, 'John') + self.assertEqual(profileObject.last_name, 'Smith') + self.assertEqual(profileObject.initials, 'JS') + self.assertEqual(profileObject.phone, '0123456789') + self.assertEqual(profileObject.email, 'test@example.com') + # All is well From c7585f6bbb65a8ce82b292db7edc1c6a1927b7ae Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 27 Aug 2015 01:36:44 +0100 Subject: [PATCH 5/7] Added missing email field to registration form --- RIGS/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RIGS/forms.py b/RIGS/forms.py index dd6015d1..faa57f76 100644 --- a/RIGS/forms.py +++ b/RIGS/forms.py @@ -21,7 +21,7 @@ class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail): class Meta: model = models.Profile - fields = ('username','first_name','last_name','initials','phone') + fields = ('username','email','first_name','last_name','initials','phone') def clean_initials(self): """ From 91866b3a57e5b204216222cc8098a90c78dbca39 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 27 Aug 2015 01:48:10 +0100 Subject: [PATCH 6/7] Removed unnecessary username field definition --- RIGS/forms.py | 1 - 1 file changed, 1 deletion(-) diff --git a/RIGS/forms.py b/RIGS/forms.py index faa57f76..0f019d18 100644 --- a/RIGS/forms.py +++ b/RIGS/forms.py @@ -12,7 +12,6 @@ from RIGS import models #Registration class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail): - username = forms.CharField(required=True, max_length=30) first_name = forms.CharField(required=False, max_length=50) last_name = forms.CharField(required=False, max_length=50) initials = forms.CharField(required=True, max_length=5) From 8e478dd7a98b5c9dd76ef2dd316eb6b8845cdc91 Mon Sep 17 00:00:00 2001 From: Tom Price Date: Thu, 27 Aug 2015 22:46:50 +0100 Subject: [PATCH 7/7] Remove implicit fields as these are not needed in the form definition. Passes all tests. --- RIGS/forms.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/RIGS/forms.py b/RIGS/forms.py index 0f019d18..d3dfb39e 100644 --- a/RIGS/forms.py +++ b/RIGS/forms.py @@ -12,10 +12,6 @@ from RIGS import models #Registration class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail): - first_name = forms.CharField(required=False, max_length=50) - last_name = forms.CharField(required=False, max_length=50) - initials = forms.CharField(required=True, max_length=5) - phone = forms.CharField(required=False, max_length=13) captcha = ReCaptchaField() class Meta: