From 5210afc772cf7a274a496bc02a4b43df6516f47d Mon Sep 17 00:00:00 2001 From: Arona Jones Date: Tue, 26 Nov 2019 17:26:32 +0000 Subject: [PATCH] Combine client authorisation information in rig detail (#373) * Combine client authorisation information in rig detail * Fix stuff for CI pep8 compliance migration --- RIGS/forms.py | 1 + RIGS/migrations/0035_auto_20191124_1319.py | 18 ++++ RIGS/rigboard.py | 2 + RIGS/templates/RIGS/event_detail.html | 103 ++++++++++----------- RIGS/views.py | 2 +- 5 files changed, 73 insertions(+), 53 deletions(-) create mode 100644 RIGS/migrations/0035_auto_20191124_1319.py diff --git a/RIGS/forms.py b/RIGS/forms.py index 9caf3016..18a81e14 100644 --- a/RIGS/forms.py +++ b/RIGS/forms.py @@ -39,6 +39,7 @@ class EmbeddedAuthenticationForm(AuthenticationForm): super().__init__(*args, **kwargs) self.fields['username'].widget.attrs.pop('autofocus', None) + class PasswordReset(PasswordResetForm): captcha = ReCaptchaField(label='Captcha') diff --git a/RIGS/migrations/0035_auto_20191124_1319.py b/RIGS/migrations/0035_auto_20191124_1319.py new file mode 100644 index 00000000..dd00494f --- /dev/null +++ b/RIGS/migrations/0035_auto_20191124_1319.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.13 on 2019-11-24 13:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('RIGS', '0034_event_risk_assessment_edit_url'), + ] + + operations = [ + migrations.AlterField( + model_name='event', + name='risk_assessment_edit_url', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='risk assessment'), + ), + ] diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index e6112b31..99c80601 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -83,6 +83,7 @@ class EventEmbed(EventDetail): class EventRA(generic.base.RedirectView): permanent = False + def get_redirect_url(self, *args, **kwargs): event = get_object_or_404(models.Event, pk=kwargs['pk']) @@ -406,6 +407,7 @@ class EventAuthoriseRequestEmailPreview(generic.DetailView): context['to_name'] = self.request.GET.get('to_name', None) return context + @method_decorator(csrf_exempt, name='dispatch') class LogRiskAssessment(generic.View): http_method_names = ["post"] diff --git a/RIGS/templates/RIGS/event_detail.html b/RIGS/templates/RIGS/event_detail.html index 5f2885b5..6a18d2f3 100644 --- a/RIGS/templates/RIGS/event_detail.html +++ b/RIGS/templates/RIGS/event_detail.html @@ -70,39 +70,6 @@ {% endif %} - - {% if event.is_rig and event.internal %} -
-
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 %}
@@ -180,31 +147,63 @@
{{ object.collector }}
{% endif %} - {% if event.is_rig %} + {% if event.is_rig and not event.internal %}
 
- - {% if object.internal %} -
Authorisation Request
-
{{ object.auth_request_to|yesno:"Yes,No" }}
- -
By
-
{{ object.auth_request_by }}
- -
At
-
{{ object.auth_request_at|date:"D d M Y H:i"|default:"" }}
- -
To
-
{{ object.auth_request_to }}
- - {% else %} -
PO
-
{{ object.purchase_order }}
- {% endif %} +
PO
+
{{ object.purchase_order }}
{% endif %}
+ {% if event.is_rig and event.internal %} +
+
+
Client Authorisation
+
+
+
Authorisation Request
+
{{ object.auth_request_to|yesno:"Yes,No" }}
+ +
By
+
{{ object.auth_request_by }}
+ +
At
+
{{ object.auth_request_at|date:"D d M Y H:i"|default:"" }}
+ +
To
+
{{ object.auth_request_to }}
+
+
 
+
+
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 %} {% if not request.is_ajax %}
{% include 'RIGS/event_detail_buttons.html' %} diff --git a/RIGS/views.py b/RIGS/views.py index aaaac7da..b197334c 100644 --- a/RIGS/views.py +++ b/RIGS/views.py @@ -62,7 +62,7 @@ def login_embed(request, **kwargs): messages.warning(request, 'Cookies do not seem to be enabled. Try logging in using a new tab.') request.method = 'GET' # Render the page without trying to login - return login(request, template_name="registration/login_embed.html", authentication_form=forms.EmbeddedAuthenticationForm) + return login(request, template_name="registration/login_embed.html", authentication_form=forms.EmbeddedAuthenticationForm) """