From 124b7a8e51043e315543c4b7830396cc5e565b8b Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Sun, 13 Dec 2020 16:26:08 +0000 Subject: [PATCH] Add space for power/rigging plans to be linked to RAs --- RIGS/migrations/0046_auto_20201213_1625.py | 34 ++++++++++++++++++++++ RIGS/models.py | 16 ++++++++-- RIGS/templates/risk_assessment_detail.html | 15 ++++++++-- RIGS/templates/risk_assessment_form.html | 4 +++ RIGS/templatetags/filters.py | 6 ++-- 5 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 RIGS/migrations/0046_auto_20201213_1625.py diff --git a/RIGS/migrations/0046_auto_20201213_1625.py b/RIGS/migrations/0046_auto_20201213_1625.py new file mode 100644 index 00000000..738d452e --- /dev/null +++ b/RIGS/migrations/0046_auto_20201213_1625.py @@ -0,0 +1,34 @@ +# Generated by Django 3.1.2 on 2020-12-13 16:25 + +import RIGS.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('RIGS', '0045_auto_20201116_1808'), + ] + + operations = [ + migrations.AddField( + model_name='riskassessment', + name='power_plan', + field=models.URLField(blank=True, help_text="Upload your power plan to the Sharepoint and submit a link", null=True, validators=[RIGS.models.validate_url]), + ), + migrations.AddField( + model_name='riskassessment', + name='rigging_plan', + field=models.URLField(blank=True, help_text="Upload your rigging plan to the Sharepoint and submit a link", null=True, validators=[RIGS.models.validate_url]), + ), + migrations.AlterField( + model_name='riskassessment', + name='contractors', + field=models.BooleanField(help_text='Are you using any external contractors?
i.e. Freelancers/Crewing Companies'), + ), + migrations.AlterField( + model_name='riskassessment', + name='other_companies', + field=models.BooleanField(help_text='Are TEC working with any other companies on site?
e.g. TEC is providing the lighting while another company does sound'), + ), + ] diff --git a/RIGS/models.py b/RIGS/models.py index 3fab3e27..d376540d 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -19,6 +19,8 @@ from decimal import Decimal from django.core.exceptions import ValidationError from django.urls import reverse_lazy +from urllib.parse import urlparse + class Profile(AbstractUser): initials = models.CharField(max_length=5, unique=True, null=True, blank=False) @@ -610,6 +612,14 @@ class Payment(models.Model, RevisionMixin): return str("payment at £{}".format(self.amount)) +def validate_url(value): + if not value: + return # Required error is done the field + obj = urlparse(value) + if not obj.hostname in ('nottinghamtec.sharepoint.com'): + raise ValidationError('URL must point to a location on the TEC Sharepoint') + + @reversion.register class RiskAssessment(models.Model, RevisionMixin): event = models.OneToOneField('Event', on_delete=models.CASCADE) @@ -617,8 +627,8 @@ class RiskAssessment(models.Model, RevisionMixin): nonstandard_equipment = models.BooleanField(help_text="Does the event require any hired in equipment or use of equipment that is not covered by " "TEC's standard risk assessments and method statements?") nonstandard_use = models.BooleanField(help_text="Are TEC using their equipment in a way that is abnormal?
i.e. Not covered by TECs standard health and safety documentation") - contractors = models.BooleanField(help_text="Are you using any external contractors?i.e. Freelancers/Crewing Companies") - other_companies = models.BooleanField(help_text="Are TEC working with any other companies on site?e.g. TEC is providing the lighting while another company does sound") + contractors = models.BooleanField(help_text="Are you using any external contractors?
i.e. Freelancers/Crewing Companies") + other_companies = models.BooleanField(help_text="Are TEC working with any other companies on site?
e.g. TEC is providing the lighting while another company does sound") crew_fatigue = models.BooleanField(help_text="Is crew fatigue likely to be a risk at any point during this event?") general_notes = models.TextField(blank=True, null=True, help_text="Did you have to consult a supervisor about any of the above? If so who did you consult and what was the outcome?") @@ -633,6 +643,7 @@ class RiskAssessment(models.Model, RevisionMixin): nonstandard_equipment_power = models.BooleanField(help_text="Does the power plan require the use of any power equipment (distros, dimmers, motor controllers, etc.) that does not belong to TEC?") multiple_electrical_environments = models.BooleanField(help_text="Will the electrical installation occupy more than one electrical environment?") power_notes = models.TextField(blank=True, null=True, help_text="Did you have to consult a supervisor about any of the above? If so who did you consult and what was the outcome?") + power_plan = models.URLField(blank=True, null=True, help_text="Upload your power plan to the Sharepoint and submit a link", validators=[validate_url]) # Sound noise_monitoring = models.BooleanField(help_text="Does the event require noise monitoring or any non-standard procedures in order to comply with health and safety legislation or site rules?") @@ -650,6 +661,7 @@ class RiskAssessment(models.Model, RevisionMixin): special_structures = models.BooleanField(help_text="Does the event require use of winch stands, motors, MPT Towers, or staging?") suspended_structures = models.BooleanField(help_text="Are any structures (excluding projector screens and IWBs) being suspended from TEC's structures?") persons_responsible_structures = models.TextField(blank=True, null=True, help_text="Who are the persons on site responsible for their use?") + rigging_plan = models.URLField(blank=True, null=True, help_text="Upload your rigging plan to the Sharepoint and submit a link", validators=[validate_url]) # Blimey that was a lot of options diff --git a/RIGS/templates/risk_assessment_detail.html b/RIGS/templates/risk_assessment_detail.html index a6d05b3f..1866ceb8 100644 --- a/RIGS/templates/risk_assessment_detail.html +++ b/RIGS/templates/risk_assessment_detail.html @@ -2,6 +2,7 @@ {% block title %}Risk Assessment for Event N{{ object.event.pk|stringformat:"05d" }} {{ object.event.name }}{% endblock %} {% load help_text from filters %} {% load yesnoi from filters %} +{% load linkornone from filters %} {% block content %}
@@ -11,7 +12,7 @@
General
-
{{ object|help_text:'nonstandard_equipment' }}
+
{{ object|help_text:'nonstandard_equipment'|safe }}
{{ object.nonstandard_equipment|yesnoi:'invert' }}
@@ -19,11 +20,11 @@
{{ object.nonstandard_use|yesnoi:'invert' }}
-
{{ object|help_text:'contractors' }}
+
{{ object|help_text:'contractors'|safe }}
{{ object.contractors|yesnoi:'invert' }}
-
{{ object|help_text:'other_companies' }}
+
{{ object|help_text:'other_companies'|safe }}
{{ object.other_companies|yesnoi:'invert' }}
@@ -74,6 +75,10 @@
{{ object.power_notes|default:'N/A'|linebreaks }}
+
{{ object|help_text:'power_plan'|safe }}
+
+ {{ object.power_plan|linkornone }} +
@@ -139,6 +144,10 @@
{{ object.persons_responsible_structures.name|default:'N/A'|linebreaks }}
+
{{ object|help_text:'rigging_plan'|safe }}
+
+ {{ object.rigging_plan|linkornone }} +
diff --git a/RIGS/templates/risk_assessment_form.html b/RIGS/templates/risk_assessment_form.html index c57eca13..d97807e3 100644 --- a/RIGS/templates/risk_assessment_form.html +++ b/RIGS/templates/risk_assessment_form.html @@ -100,6 +100,8 @@ {% include 'partials/yes_no_radio.html' with formitem=form.multiple_electrical_environments %} {% render_field form.power_notes class+="form-control" %} + + {% render_field form.power_plan class+="form-control" %} @@ -142,6 +144,8 @@ {% include 'partials/yes_no_radio.html' with formitem=form.suspended_structures %} {% render_field form.persons_responsible_structures class+="form-control mb-3" %} + + {% render_field form.rigging_plan class+="form-control" %} diff --git a/RIGS/templatetags/filters.py b/RIGS/templatetags/filters.py index 24434f3f..e4f7d1e9 100644 --- a/RIGS/templatetags/filters.py +++ b/RIGS/templatetags/filters.py @@ -179,9 +179,11 @@ def namewithnotes(obj, url, autoescape=True): @register.filter(needs_autoescape=True) -def linkornone(attr, namespace, autoescape=True): +def linkornone(attr, namespace=None, autoescape=True): if attr is not None: - return mark_safe("{}".format(namespace, attr, str(attr))) + if namespace is not None: + attr = namespace + "://" + attr + return mark_safe("{}".format(attr, str(attr))) else: return "None"