mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-02-22 06:18:24 +00:00
Event properties internal/authorised always return a explicit boolean rather than sometimes None
This commit is contained in:
@@ -177,14 +177,14 @@ class Command(BaseCommand):
|
|||||||
"asset_finance", "view_asset", "view_supplier", "asset_finance",
|
"asset_finance", "view_asset", "view_supplier", "asset_finance",
|
||||||
"add_supplier", "view_cabletype", "change_cabletype",
|
"add_supplier", "view_cabletype", "change_cabletype",
|
||||||
"add_cabletype", "view_eventchecklist", "change_eventchecklist",
|
"add_cabletype", "view_eventchecklist", "change_eventchecklist",
|
||||||
"add_eventchecklist", "view_riskassessment", "change_riskassessment",
|
"add_eventchecklist", "view_riskassessment", "change_riskassessment",
|
||||||
"add_riskassessment", "add_eventchecklistcrew", "change_eventchecklistcrew",
|
"add_riskassessment", "add_eventchecklistcrew", "change_eventchecklistcrew",
|
||||||
"delete_eventchecklistcrew", "view_eventchecklistcrew", "add_eventchecklistvehicle",
|
"delete_eventchecklistcrew", "view_eventchecklistcrew", "add_eventchecklistvehicle",
|
||||||
"change_eventchecklistvehicle",
|
"change_eventchecklistvehicle",
|
||||||
"delete_eventchecklistvehicle", "view_eventchecklistvehicle", ]
|
"delete_eventchecklistvehicle", "view_eventchecklistvehicle", ]
|
||||||
financePerms = keyholderPerms + ["add_invoice", "change_invoice", "view_invoice",
|
financePerms = keyholderPerms + ["add_invoice", "change_invoice", "view_invoice",
|
||||||
"add_payment", "change_payment", "delete_payment"]
|
"add_payment", "change_payment", "delete_payment"]
|
||||||
hsPerms = keyHolderPerms + [ "review_riskassessment", "review_eventchecklist" ]
|
hsPerms = keyholderPerms + ["review_riskassessment", "review_eventchecklist"]
|
||||||
|
|
||||||
for permId in keyholderPerms:
|
for permId in keyholderPerms:
|
||||||
self.keyholder_group.permissions.add(Permission.objects.get(codename=permId))
|
self.keyholder_group.permissions.add(Permission.objects.get(codename=permId))
|
||||||
@@ -226,8 +226,8 @@ class Command(BaseCommand):
|
|||||||
financeUser.save()
|
financeUser.save()
|
||||||
|
|
||||||
hsUser = models.Profile.objects.create(username="hs", first_name="HS", last_name="User",
|
hsUser = models.Profile.objects.create(username="hs", first_name="HS", last_name="User",
|
||||||
initials="HSU",
|
initials="HSU",
|
||||||
email="hsuser@example.com", is_active=True)
|
email="hsuser@example.com", is_active=True)
|
||||||
hsUser.groups.add(self.hs_group)
|
hsUser.groups.add(self.hs_group)
|
||||||
hsUser.groups.add(self.keyholder_group)
|
hsUser.groups.add(self.keyholder_group)
|
||||||
hsUser.set_password('hs')
|
hsUser.set_password('hs')
|
||||||
|
|||||||
@@ -443,9 +443,10 @@ class Event(models.Model, RevisionMixin):
|
|||||||
else:
|
else:
|
||||||
return endDate
|
return endDate
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def internal(self):
|
def internal(self):
|
||||||
return self.organisation and self.organisation.union_account
|
return bool(self.organisation and self.organisation.union_account)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def status_color(self):
|
def status_color(self):
|
||||||
@@ -453,7 +454,7 @@ class Event(models.Model, RevisionMixin):
|
|||||||
return "text-muted table-secondary"
|
return "text-muted table-secondary"
|
||||||
elif not self.is_rig:
|
elif not self.is_rig:
|
||||||
return "table-info"
|
return "table-info"
|
||||||
elif self.authorised and self.mic and (self.dry_hire or self.riskassessment):
|
elif self.mic and (self.dry_hire or self.riskassessment) and self.authorised:
|
||||||
return "table-success"
|
return "table-success"
|
||||||
else:
|
else:
|
||||||
return "table-warning"
|
return "table-warning"
|
||||||
@@ -587,7 +588,7 @@ class Payment(models.Model):
|
|||||||
# Probably shouldn't be doing HTML at the python level but hey...they say not to do logic in templates! :P
|
# Probably shouldn't be doing HTML at the python level but hey...they say not to do logic in templates! :P
|
||||||
def get_review_string(obj, review_link):
|
def get_review_string(obj, review_link):
|
||||||
if obj.reviewed_by:
|
if obj.reviewed_by:
|
||||||
return "<span class='badge badge-success py-2'>Reviewed by <a href='{}'>{}</a> at {}</span>".format(reverse_lazy('profile_detail', kwargs={'pk': obj.reviewed_by.pk}), obj.reviewed_by, obj.reviewed_at.strftime("%d/%m/%Y %H:%M"))
|
return "<span class='badge badge-success py-2'>Reviewed by <a href='{}'>{}</a> at {}</span>".format(reverse_lazy('profile_detail', kwargs={'pk': obj.reviewed_by.pk}), obj.reviewed_by, obj.reviewed_at.strftime("%d/%m/%Y %H:%M"))
|
||||||
else:
|
else:
|
||||||
return "<a class='btn btn-success my-2' href='{}'>Mark Reviewed</a>".format(reverse_lazy(review_link, kwargs={'pk': obj.pk}))
|
return "<a class='btn btn-success my-2' href='{}'>Mark Reviewed</a>".format(reverse_lazy(review_link, kwargs={'pk': obj.pk}))
|
||||||
|
|
||||||
@@ -685,8 +686,8 @@ class EventChecklist(models.Model, RevisionMixin):
|
|||||||
extinguishers_location = models.CharField(max_length=255, help_text="Location of fire extinguishers")
|
extinguishers_location = models.CharField(max_length=255, help_text="Location of fire extinguishers")
|
||||||
|
|
||||||
# Small Electrical Checks
|
# Small Electrical Checks
|
||||||
rcds = models.BooleanField(blank=True,null=True,help_text="RCDs installed where needed and tested?")
|
rcds = models.BooleanField(blank=True, null=True, help_text="RCDs installed where needed and tested?")
|
||||||
supply_test = models.BooleanField(blank=True,null=True,help_text="Electrical supplies tested?<br><small>(using socket tester)</small>")
|
supply_test = models.BooleanField(blank=True, null=True, help_text="Electrical supplies tested?<br><small>(using socket tester)</small>")
|
||||||
|
|
||||||
# Shared electrical checks
|
# Shared electrical checks
|
||||||
earthing = models.BooleanField(help_text="Equipment appropriately earthed?<br><small>(truss, stage, generators etc)</small>")
|
earthing = models.BooleanField(help_text="Equipment appropriately earthed?<br><small>(truss, stage, generators etc)</small>")
|
||||||
@@ -694,31 +695,31 @@ class EventChecklist(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
medium_event = models.BooleanField()
|
medium_event = models.BooleanField()
|
||||||
# Medium Electrical Checks
|
# Medium Electrical Checks
|
||||||
source_rcd = models.BooleanField(blank=True,null=True,help_text="Source RCD protected?<br><small>(if cable is more than 3m long) </small>")
|
source_rcd = models.BooleanField(blank=True, null=True, help_text="Source RCD protected?<br><small>(if cable is more than 3m long) </small>")
|
||||||
labelling = models.BooleanField(blank=True,null=True, help_text="Appropriate and clear labelling on distribution and cabling?")
|
labelling = models.BooleanField(blank=True, null=True, help_text="Appropriate and clear labelling on distribution and cabling?")
|
||||||
# First Distro
|
# First Distro
|
||||||
fd_voltage_l1 = models.IntegerField(blank=True,null=True, verbose_name="First Distro Voltage L1-N", help_text="L1 - N")
|
fd_voltage_l1 = models.IntegerField(blank=True, null=True, verbose_name="First Distro Voltage L1-N", help_text="L1 - N")
|
||||||
fd_voltage_l2 = models.IntegerField(blank=True,null=True,verbose_name="First Distro Voltage L2-N", help_text="L2 - N")
|
fd_voltage_l2 = models.IntegerField(blank=True, null=True, verbose_name="First Distro Voltage L2-N", help_text="L2 - N")
|
||||||
fd_voltage_l3 = models.IntegerField(blank=True,null=True,verbose_name="First Distro Voltage L3-N", help_text="L3 - N")
|
fd_voltage_l3 = models.IntegerField(blank=True, null=True, verbose_name="First Distro Voltage L3-N", help_text="L3 - N")
|
||||||
fd_phase_rotation = models.BooleanField(blank=True,null=True,verbose_name="Phase Rotation", help_text="Phase Rotation<br><small>(if required)</small>")
|
fd_phase_rotation = models.BooleanField(blank=True, null=True, verbose_name="Phase Rotation", help_text="Phase Rotation<br><small>(if required)</small>")
|
||||||
fd_earth_fault = models.IntegerField(blank=True,null=True,verbose_name="Earth Fault Loop Impedance", help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
fd_earth_fault = models.IntegerField(blank=True, null=True, verbose_name="Earth Fault Loop Impedance", help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
||||||
fd_pssc = models.IntegerField(blank=True,null=True,verbose_name="PSCC", help_text="Prospective Short Circuit Current")
|
fd_pssc = models.IntegerField(blank=True, null=True, verbose_name="PSCC", help_text="Prospective Short Circuit Current")
|
||||||
#Worst case points
|
# Worst case points
|
||||||
w1_description = models.CharField(blank=True,null=True,max_length=255, help_text="Description")
|
w1_description = models.CharField(blank=True, null=True, max_length=255, help_text="Description")
|
||||||
w1_polarity = models.BooleanField(blank=True,null=True,help_text="Polarity Checked?")
|
w1_polarity = models.BooleanField(blank=True, null=True, help_text="Polarity Checked?")
|
||||||
w1_voltage = models.IntegerField(blank=True,null=True,help_text="Voltage")
|
w1_voltage = models.IntegerField(blank=True, null=True, help_text="Voltage")
|
||||||
w1_earth_fault = models.IntegerField(blank=True,null=True,help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
w1_earth_fault = models.IntegerField(blank=True, null=True, help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
||||||
w2_description = models.CharField(blank=True,null=True,max_length=255, help_text="Description")
|
w2_description = models.CharField(blank=True, null=True, max_length=255, help_text="Description")
|
||||||
w2_polarity = models.BooleanField(blank=True,null=True,help_text="Polarity Checked?")
|
w2_polarity = models.BooleanField(blank=True, null=True, help_text="Polarity Checked?")
|
||||||
w2_voltage = models.IntegerField(blank=True,null=True,help_text="Voltage")
|
w2_voltage = models.IntegerField(blank=True, null=True, help_text="Voltage")
|
||||||
w2_earth_fault = models.IntegerField(blank=True,null=True,help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
w2_earth_fault = models.IntegerField(blank=True, null=True, help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
||||||
w3_description = models.CharField(blank=True,null=True,max_length=255, help_text="Description")
|
w3_description = models.CharField(blank=True, null=True, max_length=255, help_text="Description")
|
||||||
w3_polarity = models.BooleanField(blank=True,null=True,help_text="Polarity Checked?")
|
w3_polarity = models.BooleanField(blank=True, null=True, help_text="Polarity Checked?")
|
||||||
w3_voltage = models.IntegerField(blank=True,null=True,help_text="Voltage")
|
w3_voltage = models.IntegerField(blank=True, null=True, help_text="Voltage")
|
||||||
w3_earth_fault = models.IntegerField(blank=True,null=True,help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
w3_earth_fault = models.IntegerField(blank=True, null=True, help_text="Earth Fault Loop Impedance (Z<small>S</small>)")
|
||||||
|
|
||||||
all_rcds_tested = models.BooleanField(blank=True,null=True,help_text="All circuit RCDs tested?<br><small>(using test button)</small>")
|
all_rcds_tested = models.BooleanField(blank=True, null=True, help_text="All circuit RCDs tested?<br><small>(using test button)</small>")
|
||||||
public_sockets_tested = models.BooleanField(blank=True,null=True,help_text="Public/Performer accessible circuits tested?<br><small>(using socket tester)</small>")
|
public_sockets_tested = models.BooleanField(blank=True, null=True, help_text="Public/Performer accessible circuits tested?<br><small>(using socket tester)</small>")
|
||||||
|
|
||||||
reviewed_at = models.DateTimeField(null=True)
|
reviewed_at = models.DateTimeField(null=True)
|
||||||
reviewed_by = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True,
|
reviewed_by = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True,
|
||||||
@@ -732,17 +733,17 @@ class EventChecklist(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
errdict = {}
|
errdict = {}
|
||||||
if self.earthing == None or self.pat == None:
|
if self.earthing is None or self.pat is None:
|
||||||
errdict['earthing'] = 'Fill out the electrical checks'
|
errdict['earthing'] = 'Fill out the electrical checks'
|
||||||
|
|
||||||
if not self.medium_event and (self.rcds == None or self.supply_test == None):
|
if not self.medium_event and (self.rcds is None or self.supply_test is None):
|
||||||
errdict['rcds'] = 'Fill out the small event electrical checks'
|
errdict['rcds'] = 'Fill out the small event electrical checks'
|
||||||
|
|
||||||
if self.medium_event:
|
if self.medium_event:
|
||||||
if self.source_rcd == None or self.labelling == None or self.all_rcds_tested == None or self.public_sockets_tested == None:
|
if self.source_rcd is None or self.labelling is None or self.all_rcds_tested is None or self.public_sockets_tested is None:
|
||||||
errdict['source_rcd'] = 'Fill out the medium event electrical checks'
|
errdict['source_rcd'] = 'Fill out the medium event electrical checks'
|
||||||
|
|
||||||
if self.w1_description == None or self.w1_polarity == None or self.w1_voltage == None or self.w1_earth_fault == None:
|
if self.w1_description is None or self.w1_polarity is None or self.w1_voltage is None or self.w1_earth_fault is None:
|
||||||
errdict['w1_description'] = 'Fully complete at least the first worst case point'
|
errdict['w1_description'] = 'Fully complete at least the first worst case point'
|
||||||
|
|
||||||
if errdict != {}: # If there was an error when validation
|
if errdict != {}: # If there was an error when validation
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
<a href="{% url 'event_create' %}" class="btn btn-success my-3 float-right">New <i class="fas fa-plus"></i></a>
|
<a href="{% url 'event_create' %}" class="btn btn-success my-3 float-right">New <i class="fas fa-plus"></i></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<p>Key: <span class="badge badge-success mr-1">Ready</span><span class="badge badge-warning mr-1">Action Required</span><span class="badge badge-secondary mr-1">Cancelled</span><span class="badge badge-info">Non-Rig</span></p>
|
||||||
{% include 'event_table.html' %}
|
{% include 'event_table.html' %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ def yesnoi(boolean, invert=False, autoescape=True):
|
|||||||
value += ' <span class="fas fa-exclamation" style="color: red;"></span>'
|
value += ' <span class="fas fa-exclamation" style="color: red;"></span>'
|
||||||
return mark_safe(value)
|
return mark_safe(value)
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def title_spaced(string):
|
def title_spaced(string):
|
||||||
return title(string).replace('_', ' ')
|
return title(string).replace('_', ' ')
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ class TestEventDuplicate(BaseRigboardTest):
|
|||||||
self.assertEqual(newEvent.auth_request_by, None)
|
self.assertEqual(newEvent.auth_request_by, None)
|
||||||
self.assertEqual(newEvent.auth_request_at, None)
|
self.assertEqual(newEvent.auth_request_at, None)
|
||||||
|
|
||||||
self.assertFalse(hasattr(newEvent, 'authorised'))
|
self.assertFalse(newEvent.authorised)
|
||||||
|
|
||||||
self.assertNotIn("N%05d" % self.testEvent.pk, self.driver.find_element_by_xpath('//h1').text)
|
self.assertNotIn("N%05d" % self.testEvent.pk, self.driver.find_element_by_xpath('//h1').text)
|
||||||
self.assertNotIn("Event data duplicated but not yet saved", self.page.warning) # Check info message not visible
|
self.assertNotIn("Event data duplicated but not yet saved", self.page.warning) # Check info message not visible
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ class EventTestCase(TestCase):
|
|||||||
self.assertEqual(models.Event.objects.count(), 18, "Incorrect number of events, check setup")
|
self.assertEqual(models.Event.objects.count(), 18, "Incorrect number of events, check setup")
|
||||||
|
|
||||||
def test_rig_count(self):
|
def test_rig_count(self):
|
||||||
# by my count this is 7
|
# Changed to not include unreturned dry hires in rig count
|
||||||
self.assertEqual(models.Event.objects.rig_count(), 8)
|
self.assertEqual(models.Event.objects.rig_count(), 7)
|
||||||
|
|
||||||
def test_current_events(self):
|
def test_current_events(self):
|
||||||
current_events = models.Event.objects.current_events()
|
current_events = models.Event.objects.current_events()
|
||||||
@@ -374,8 +374,8 @@ class EventAuthorisationTestCase(TestCase):
|
|||||||
is_superuser=True # lazily grant all permissions
|
is_superuser=True # lazily grant all permissions
|
||||||
)[0]
|
)[0]
|
||||||
self.person = models.Person.objects.create(name='Authorisation Test Person')
|
self.person = models.Person.objects.create(name='Authorisation Test Person')
|
||||||
self.organisation = models.Organisation.objects.create(name='Authorisation Test Organisation')
|
self.organisation = models.Organisation.objects.create(name='Authorisation Test Organisation', union_account=True)
|
||||||
self.event = models.Event.objects.create(name="AuthorisationTestCase", person=self.person,
|
self.event = models.Event.objects.create(name="AuthorisationTestCase", person=self.person, organisation=self.organisation,
|
||||||
start_date=date.today())
|
start_date=date.today())
|
||||||
# Add some items
|
# Add some items
|
||||||
models.EventItem.objects.create(event=self.event, name="Authorisation test item", quantity=2, cost=123.45,
|
models.EventItem.objects.create(event=self.event, name="Authorisation test item", quantity=2, cost=123.45,
|
||||||
|
|||||||
@@ -592,7 +592,7 @@ class TestVersioningViews(TestCase):
|
|||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_activity_table_loads_successfully(self):
|
def test_activity_table_loads_successfully(self):
|
||||||
request_url = reverse('asset_activity_table')
|
request_url = reverse('assets_activity_table')
|
||||||
|
|
||||||
response = self.client.get(request_url, follow=True)
|
response = self.client.get(request_url, follow=True)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class ModelComparison(object):
|
|||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def item_changes(self):
|
def item_changes(self):
|
||||||
if self.follow:
|
if self.follow and self.version.object is not None:
|
||||||
item_type = ContentType.objects.get_for_model(self.version.object)
|
item_type = ContentType.objects.get_for_model(self.version.object)
|
||||||
old_item_versions = self.version.parent.revision.version_set.exclude(content_type=item_type)
|
old_item_versions = self.version.parent.revision.version_set.exclude(content_type=item_type)
|
||||||
new_item_versions = self.version.revision.version_set.exclude(content_type=item_type)
|
new_item_versions = self.version.revision.version_set.exclude(content_type=item_type)
|
||||||
|
|||||||
Reference in New Issue
Block a user