mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-02-09 16:29:41 +00:00
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...
This commit is contained in:
30
RIGS/migrations/0030_auth_request_sending.py
Normal file
30
RIGS/migrations/0030_auth_request_sending.py
Normal file
@@ -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),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -334,6 +334,11 @@ class Event(models.Model, RevisionMixin):
|
|||||||
payment_received = models.CharField(max_length=255, blank=True, null=True)
|
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')
|
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
|
# Calculated values
|
||||||
"""
|
"""
|
||||||
EX Vat
|
EX Vat
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ class EventAuthorisationRequest(generic.FormView, generic.detail.SingleObjectMix
|
|||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
if self.request.is_ajax():
|
if self.request.is_ajax():
|
||||||
url = reverse_lazy('closemodal')
|
url = reverse_lazy('closemodal')
|
||||||
messages.info(self.request, "$('.event-authorise-request').addClass('btn-success')")
|
messages.info(self.request, "location.reload()")
|
||||||
else:
|
else:
|
||||||
url = reverse_lazy('event_detail', kwargs={
|
url = reverse_lazy('event_detail', kwargs={
|
||||||
'pk': self.object.pk,
|
'pk': self.object.pk,
|
||||||
@@ -310,6 +310,11 @@ class EventAuthorisationRequest(generic.FormView, generic.detail.SingleObjectMix
|
|||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
email = form.cleaned_data['email']
|
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 = {
|
context = {
|
||||||
'object': self.object,
|
'object': self.object,
|
||||||
|
|||||||
@@ -70,6 +70,39 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if event.is_rig %}
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">Client Authorisation</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<dl class="dl-horizontal">
|
||||||
|
<dt>Authorised</dt>
|
||||||
|
<dd>{{ object.authorised|yesno:"Yes,No" }}</dd>
|
||||||
|
|
||||||
|
<dt>Authorised by</dt>
|
||||||
|
<dd>
|
||||||
|
{% if object.authorisation %}
|
||||||
|
{{ object.authorisation.name }}
|
||||||
|
(<a href="mailto:{{ object.authorisation.email }}">{{ object.authorisation.email }}</a>)
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt>Authorised at</dt>
|
||||||
|
<dd>{{ object.authorisation.last_edited_at }}</dd>
|
||||||
|
|
||||||
|
<dt>Authorised amount</dt>
|
||||||
|
<dd>
|
||||||
|
{% if object.authorisation %}
|
||||||
|
£ {{ object.authorisation.amount|floatformat:"2" }}
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt>Requested by</dt>
|
||||||
|
<dd>{{ object.authorisation.sent_by }}</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="col-sm-12 {% if event.is_rig %}col-md-6 col-lg-7{% endif %}">
|
<div class="col-sm-12 {% if event.is_rig %}col-md-6 col-lg-7{% endif %}">
|
||||||
@@ -150,29 +183,17 @@
|
|||||||
{% if event.is_rig %}
|
{% if event.is_rig %}
|
||||||
<dd> </dd>
|
<dd> </dd>
|
||||||
|
|
||||||
<dt>Authorised</dt>
|
<dt>Authorisation Request</dt>
|
||||||
<dd>{{ object.authorised|yesno:"Yes,No" }}</dd>
|
<dd>{{ object.auth_request_to|yesno:"Yes,No" }}</dd>
|
||||||
|
|
||||||
<dt>Authorised by</dt>
|
<dt>By</dt>
|
||||||
<dd>
|
<dd>{{ object.auth_request_by }}</dd>
|
||||||
{% if object.authorised %}
|
|
||||||
{{ object.authorisation.name }}
|
|
||||||
(<a href="mailto:{{ object.authorisation.email }}">{{ object.authorisation.email }}</a>)
|
|
||||||
{% endif %}
|
|
||||||
</dd>
|
|
||||||
|
|
||||||
<dt>Authorised at</dt>
|
<dt>At</dt>
|
||||||
<dd>{{ object.authorisation.last_edited_at }}</dd>
|
<dd>{{ object.auth_request_at|date:"D d M Y H:i"|default:"" }}</dd>
|
||||||
|
|
||||||
<dt>Authorised amount</dt>
|
<dt>To</dt>
|
||||||
<dd>
|
<dd>{{ object.auth_request_to }}</dd>
|
||||||
{% if object.authorised %}
|
|
||||||
£ {{ object.authorisation.amount|floatformat:"2" }}
|
|
||||||
{% endif %}
|
|
||||||
</dd>
|
|
||||||
|
|
||||||
<dt>Authorsation request sent by</dt>
|
|
||||||
<dd>{{ object.authorisation.sent_by }}</dd>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,10 +11,18 @@
|
|||||||
class="glyphicon glyphicon-duplicate"></span> <span
|
class="glyphicon glyphicon-duplicate"></span> <span
|
||||||
class="hidden-xs">Duplicate</span></a>
|
class="hidden-xs">Duplicate</span></a>
|
||||||
{% if event.is_rig %}
|
{% if event.is_rig %}
|
||||||
<a class="btn btn-default item-add modal-href event-authorise-request"
|
<a class="btn btn-default item-add modal-href event-authorise-request
|
||||||
|
{% if event.authorised %}
|
||||||
|
btn-success
|
||||||
|
{% elif event.authorisation and event.authorisation.amount != event.total and event.authorisation.last_edited_at > event.auth_request_at %}
|
||||||
|
btn-warning
|
||||||
|
{% elif event.auth_request_to %}
|
||||||
|
btn-info
|
||||||
|
{% endif %}
|
||||||
|
"
|
||||||
href="{% url 'event_authorise_request' object.pk %}">
|
href="{% url 'event_authorise_request' object.pk %}">
|
||||||
<span class="glyphicon glyphicon-send"></span>
|
<span class="glyphicon glyphicon-send"></span>
|
||||||
Authorisation Request
|
<span class="hidden-xs">Authorisation Request</span>
|
||||||
</a>
|
</a>
|
||||||
{% if perms.RIGS.add_invoice %}
|
{% if perms.RIGS.add_invoice %}
|
||||||
<a id="invoiceDropdownLabel" href="{% url 'invoice_event' event.pk %}" class="btn
|
<a id="invoiceDropdownLabel" href="{% url 'invoice_event' event.pk %}" class="btn
|
||||||
|
|||||||
@@ -1086,3 +1086,9 @@ class TECEventAuthorisationTest(TestCase):
|
|||||||
email = mail.outbox[0]
|
email = mail.outbox[0]
|
||||||
self.assertIn('client@functional.test', email.to)
|
self.assertIn('client@functional.test', email.to)
|
||||||
self.assertIn('/event/%d/' % (self.event.pk), email.body)
|
self.assertIn('/event/%d/' % (self.event.pk), email.body)
|
||||||
|
|
||||||
|
# Check sent by details are populated
|
||||||
|
self.event.refresh_from_db()
|
||||||
|
self.assertEqual(self.event.auth_request_by, self.profile)
|
||||||
|
self.assertEqual(self.event.auth_request_to, 'client@functional.test')
|
||||||
|
self.assertIsNotNone(self.event.auth_request_at)
|
||||||
|
|||||||
Reference in New Issue
Block a user