diff --git a/PyRIGS/urls.py b/PyRIGS/urls.py
index 525480b3..b2369f9c 100644
--- a/PyRIGS/urls.py
+++ b/PyRIGS/urls.py
@@ -7,7 +7,6 @@ from django.conf import settings
from django.views.decorators.clickjacking import xframe_options_exempt
from django.contrib.auth.views import LoginView
from django.views.generic import TemplateView
-from registration.backends.default.views import RegistrationView
from PyRIGS.decorators import permission_required_with_403
import RIGS
import users
diff --git a/RIGS/hs.py b/RIGS/hs.py
index 0f94a40e..9f04150d 100644
--- a/RIGS/hs.py
+++ b/RIGS/hs.py
@@ -7,6 +7,7 @@ from reversion import revisions as reversion
from django.db.models import AutoField, ManyToOneRel
from django.contrib import messages
+
class EventRiskAssessmentCreate(generic.CreateView):
model = models.RiskAssessment
template_name = 'risk_assessment_form.html'
diff --git a/RIGS/ical.py b/RIGS/ical.py
index bd3dfcba..3940390b 100644
--- a/RIGS/ical.py
+++ b/RIGS/ical.py
@@ -102,7 +102,7 @@ class CalendarICS(ICalFeed):
return item.earliest_time
def item_end_datetime(self, item):
- if type(item.latest_time) == datetime.date: # Ical end_datetime is non-inclusive, so add a day
+ if isinstance(item.latest_time, datetime.date): # Ical end_datetime is non-inclusive, so add a day
return item.latest_time + datetime.timedelta(days=1)
return item.latest_time
diff --git a/RIGS/migrations/0048_auto_20201227_1749.py b/RIGS/migrations/0048_auto_20201227_1749.py
new file mode 100644
index 00000000..60703743
--- /dev/null
+++ b/RIGS/migrations/0048_auto_20201227_1749.py
@@ -0,0 +1,24 @@
+# Generated by Django 3.1.2 on 2020-12-27 17:49
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('RIGS', '0047_auto_20201213_1642'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='riskassessment',
+ name='event_size',
+ ),
+ migrations.AlterField(
+ model_name='riskassessment',
+ name='power_mic',
+ field=models.ForeignKey(blank=True, help_text='Who is the Power MIC? (if yes to the above question, this person must be a Power Technician or Power Supervisor)', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='power_mic', to=settings.AUTH_USER_MODEL, verbose_name='Power MIC'),
+ ),
+ ]
diff --git a/RIGS/models.py b/RIGS/models.py
index 6206fdb2..7d7427e6 100644
--- a/RIGS/models.py
+++ b/RIGS/models.py
@@ -616,7 +616,7 @@ 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'):
+ if obj.hostname not in ('nottinghamtec.sharepoint.com'):
raise ValidationError('URL must point to a location on the TEC Sharepoint')
@@ -638,12 +638,12 @@ class RiskAssessment(models.Model, RevisionMixin):
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?")
# Power
- event_size = models.IntegerField(blank=True, null=True, choices=SIZES)
+ # event_size = models.IntegerField(blank=True, null=True, choices=SIZES)
big_power = models.BooleanField(help_text="Does the event require larger power supplies than 13A or 16A single phase wall sockets, or draw more than 20A total current?")
# If yes to the above two, you must answer...
power_mic = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='power_mic', blank=True, null=True,
verbose_name="Power MIC", on_delete=models.CASCADE, help_text="Who is the Power MIC? (if yes to the above question, this person must be a Power Technician or Power Supervisor)")
- outside = models.BooleanField(help_text="Is the event outdoors?")
+ outside = models.BooleanField(help_text="Is the event outdoors?")
generators = models.BooleanField(help_text="Will generators be used?")
other_companies_power = models.BooleanField(help_text="Will TEC be supplying power to any other companies?")
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?")
@@ -704,13 +704,6 @@ class RiskAssessment(models.Model, RevisionMixin):
# Check for idiots
if not self.outside and self.generators:
raise forms.ValidationError("Engage brain, please. No generators indoors!(!)")
- # Confirm event size. Check all except generators, since generators entails outside
- if self.outside or self.other_companies_power or self.nonstandard_equipment_power or self.multiple_electrical_environments:
- self.event_size = self.LARGE[0]
- elif self.big_power:
- self.event_size = self.MEDIUM[0]
- else:
- self.event_size = self.SMALL[0]
class Meta:
ordering = ['event']
@@ -718,6 +711,16 @@ class RiskAssessment(models.Model, RevisionMixin):
('review_riskassessment', 'Can review Risk Assessments')
]
+ @property
+ def event_size(self):
+ # Confirm event size. Check all except generators, since generators entails outside
+ if self.outside or self.other_companies_power or self.nonstandard_equipment_power or self.multiple_electrical_environments:
+ return self.LARGE[0]
+ elif self.big_power:
+ return self.MEDIUM[0]
+ else:
+ return self.SMALL[0]
+
@property
def activity_feed_string(self):
return str(self.event)
diff --git a/RIGS/templates/risk_assessment_form.html b/RIGS/templates/risk_assessment_form.html
index 0d723404..e2936cdd 100644
--- a/RIGS/templates/risk_assessment_form.html
+++ b/RIGS/templates/risk_assessment_form.html
@@ -41,6 +41,14 @@
$('#{{ form.power_notes.id_for_label }}').prop('required', parseBool(this.value));
$('#{{ form.power_plan.id_for_label }}').prop('required', parseBool(this.value));
});
+ $('input[type=radio][name=special_structures]').change(function() {
+ $('#{{ form.persons_responsible_structures.id_for_label }}').prop('hidden', !parseBool(this.value)).prop('required', parseBool(this.value));
+ $('label[for={{ form.persons_responsible_structures.id_for_label }}]').prop('hidden', !parseBool(this.value));
+ });
+ $('input[type=radio][name=suspended_structures]').change(function() {
+ $('#{{ form.rigging_plan.id_for_label }}').prop('hidden', !parseBool(this.value)).prop('required', parseBool(this.value));
+ $('label[for={{ form.rigging_plan.id_for_label }}]').prop('hidden', !parseBool(this.value));
+ });
{% endblock %}
@@ -110,7 +118,7 @@
{% endif %}
-
If the answer is yes to any of the below questions this is a Large Event and you must consult a power supervisor
+
If the answer is yes to ANY of the below questions this is a Large Event and you must consult a power supervisor
{% include 'partials/yes_no_radio.html' with formitem=form.outside %}
{% include 'partials/yes_no_radio.html' with formitem=form.generators label="Will generators be used?" %}
{% include 'partials/yes_no_radio.html' with formitem=form.other_companies_power %}
@@ -159,11 +167,11 @@