From 331dab20f74f4b827a3dc50d89ed1bd36f9c67cc Mon Sep 17 00:00:00 2001 From: Tom Price Date: Wed, 19 Apr 2017 18:14:36 +0100 Subject: [PATCH] Add basic tracking of when an event authorisation request was sent. Designed and requested by Ross because he can't remember if he's push a button... --- RIGS/migrations/0030_auth_request_sending.py | 30 +++++++++ RIGS/models.py | 5 ++ RIGS/rigboard.py | 7 ++- RIGS/templates/RIGS/event_detail.html | 61 +++++++++++++------ RIGS/templates/RIGS/event_detail_buttons.html | 14 ++++- RIGS/test_functional.py | 6 ++ 6 files changed, 99 insertions(+), 24 deletions(-) create mode 100644 RIGS/migrations/0030_auth_request_sending.py diff --git a/RIGS/migrations/0030_auth_request_sending.py b/RIGS/migrations/0030_auth_request_sending.py new file mode 100644 index 00000000..7243e9a7 --- /dev/null +++ b/RIGS/migrations/0030_auth_request_sending.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +from django.conf import settings + + +class Migration(migrations.Migration): + + dependencies = [ + ('RIGS', '0029_eventauthorisation_sent_by'), + ] + + operations = [ + migrations.AddField( + model_name='event', + name='auth_request_at', + field=models.DateTimeField(null=True, blank=True), + ), + migrations.AddField( + model_name='event', + name='auth_request_by', + field=models.ForeignKey(blank=True, to=settings.AUTH_USER_MODEL, null=True), + ), + migrations.AddField( + model_name='event', + name='auth_request_to', + field=models.EmailField(max_length=254, null=True, blank=True), + ), + ] diff --git a/RIGS/models.py b/RIGS/models.py index 4a5f6988..89ec852b 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -334,6 +334,11 @@ class Event(models.Model, RevisionMixin): payment_received = models.CharField(max_length=255, blank=True, null=True) collector = models.CharField(max_length=255, blank=True, null=True, verbose_name='collected by') + # Authorisation request details + auth_request_by = models.ForeignKey('Profile', null=True, blank=True) + auth_request_at = models.DateTimeField(null=True, blank=True) + auth_request_to = models.EmailField(null=True, blank=True) + # Calculated values """ EX Vat diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index 9213e900..06ab03d1 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -300,7 +300,7 @@ class EventAuthorisationRequest(generic.FormView, generic.detail.SingleObjectMix def get_success_url(self): if self.request.is_ajax(): url = reverse_lazy('closemodal') - messages.info(self.request, "$('.event-authorise-request').addClass('btn-success')") + messages.info(self.request, "location.reload()") else: url = reverse_lazy('event_detail', kwargs={ 'pk': self.object.pk, @@ -310,6 +310,11 @@ class EventAuthorisationRequest(generic.FormView, generic.detail.SingleObjectMix def form_valid(self, form): email = form.cleaned_data['email'] + event = self.object + event.auth_request_by = self.request.user + event.auth_request_at = datetime.datetime.now() + event.auth_request_to = email + event.save() context = { 'object': self.object, diff --git a/RIGS/templates/RIGS/event_detail.html b/RIGS/templates/RIGS/event_detail.html index 4a803e1a..051aec4f 100644 --- a/RIGS/templates/RIGS/event_detail.html +++ b/RIGS/templates/RIGS/event_detail.html @@ -70,6 +70,39 @@ {% endif %} + + {% if event.is_rig %} +
+
Client Authorisation
+
+
+
Authorised
+
{{ object.authorised|yesno:"Yes,No" }}
+ +
Authorised by
+
+ {% if object.authorisation %} + {{ object.authorisation.name }} + ({{ object.authorisation.email }}) + {% endif %} +
+ +
Authorised at
+
{{ object.authorisation.last_edited_at }}
+ +
Authorised amount
+
+ {% if object.authorisation %} + £ {{ object.authorisation.amount|floatformat:"2" }} + {% endif %} +
+ +
Requested by
+
{{ object.authorisation.sent_by }}
+
+
+
+ {% endif %} {% endif %}
@@ -150,29 +183,17 @@ {% if event.is_rig %}
 
-
Authorised
-
{{ object.authorised|yesno:"Yes,No" }}
+
Authorisation Request
+
{{ object.auth_request_to|yesno:"Yes,No" }}
-
Authorised by
-
- {% if object.authorised %} - {{ object.authorisation.name }} - ({{ object.authorisation.email }}) - {% endif %} -
+
By
+
{{ object.auth_request_by }}
-
Authorised at
-
{{ object.authorisation.last_edited_at }}
+
At
+
{{ object.auth_request_at|date:"D d M Y H:i"|default:"" }}
-
Authorised amount
-
- {% if object.authorised %} - £ {{ object.authorisation.amount|floatformat:"2" }} - {% endif %} -
- -
Authorsation request sent by
-
{{ object.authorisation.sent_by }}
+
To
+
{{ object.auth_request_to }}
{% endif %}
diff --git a/RIGS/templates/RIGS/event_detail_buttons.html b/RIGS/templates/RIGS/event_detail_buttons.html index 7f91db83..0c1adae3 100644 --- a/RIGS/templates/RIGS/event_detail_buttons.html +++ b/RIGS/templates/RIGS/event_detail_buttons.html @@ -11,10 +11,18 @@ class="glyphicon glyphicon-duplicate"> {% if event.is_rig %} - + - Authorisation Request + {% if perms.RIGS.add_invoice %}