diff --git a/RIGS/management/commands/generateSampleRIGSData.py b/RIGS/management/commands/generateSampleRIGSData.py index f60f9e5d..292395ac 100644 --- a/RIGS/management/commands/generateSampleRIGSData.py +++ b/RIGS/management/commands/generateSampleRIGSData.py @@ -177,14 +177,14 @@ class Command(BaseCommand): "asset_finance", "view_asset", "view_supplier", "asset_finance", "add_supplier", "view_cabletype", "change_cabletype", "add_cabletype", "view_eventchecklist", "change_eventchecklist", - "add_eventchecklist", "view_riskassessment", "change_riskassessment", - "add_riskassessment", "add_eventchecklistcrew", "change_eventchecklistcrew", - "delete_eventchecklistcrew", "view_eventchecklistcrew", "add_eventchecklistvehicle", - "change_eventchecklistvehicle", - "delete_eventchecklistvehicle", "view_eventchecklistvehicle", ] + "add_eventchecklist", "view_riskassessment", "change_riskassessment", + "add_riskassessment", "add_eventchecklistcrew", "change_eventchecklistcrew", + "delete_eventchecklistcrew", "view_eventchecklistcrew", "add_eventchecklistvehicle", + "change_eventchecklistvehicle", + "delete_eventchecklistvehicle", "view_eventchecklistvehicle", ] financePerms = keyholderPerms + ["add_invoice", "change_invoice", "view_invoice", "add_payment", "change_payment", "delete_payment"] - hsPerms = keyHolderPerms + [ "review_riskassessment", "review_eventchecklist" ] + hsPerms = keyholderPerms + ["review_riskassessment", "review_eventchecklist"] for permId in keyholderPerms: self.keyholder_group.permissions.add(Permission.objects.get(codename=permId)) @@ -226,8 +226,8 @@ class Command(BaseCommand): financeUser.save() hsUser = models.Profile.objects.create(username="hs", first_name="HS", last_name="User", - initials="HSU", - email="hsuser@example.com", is_active=True) + initials="HSU", + email="hsuser@example.com", is_active=True) hsUser.groups.add(self.hs_group) hsUser.groups.add(self.keyholder_group) hsUser.set_password('hs') diff --git a/RIGS/models.py b/RIGS/models.py index c628e1d8..34485425 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -443,9 +443,10 @@ class Event(models.Model, RevisionMixin): else: return endDate + @property def internal(self): - return self.organisation and self.organisation.union_account + return bool(self.organisation and self.organisation.union_account) @property def status_color(self): @@ -453,7 +454,7 @@ class Event(models.Model, RevisionMixin): return "text-muted table-secondary" elif not self.is_rig: 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" else: 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 def get_review_string(obj, review_link): if obj.reviewed_by: - return "Reviewed by {} at {}".format(reverse_lazy('profile_detail', kwargs={'pk': obj.reviewed_by.pk}), obj.reviewed_by, obj.reviewed_at.strftime("%d/%m/%Y %H:%M")) + return "Reviewed by {} at {}".format(reverse_lazy('profile_detail', kwargs={'pk': obj.reviewed_by.pk}), obj.reviewed_by, obj.reviewed_at.strftime("%d/%m/%Y %H:%M")) else: return "Mark Reviewed".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") # Small Electrical Checks - 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?
(using socket tester)") + 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?
(using socket tester)") # Shared electrical checks earthing = models.BooleanField(help_text="Equipment appropriately earthed?
(truss, stage, generators etc)") @@ -694,31 +695,31 @@ class EventChecklist(models.Model, RevisionMixin): medium_event = models.BooleanField() # Medium Electrical Checks - source_rcd = models.BooleanField(blank=True,null=True,help_text="Source RCD protected?
(if cable is more than 3m long) ") - labelling = models.BooleanField(blank=True,null=True, help_text="Appropriate and clear labelling on distribution and cabling?") + source_rcd = models.BooleanField(blank=True, null=True, help_text="Source RCD protected?
(if cable is more than 3m long) ") + labelling = models.BooleanField(blank=True, null=True, help_text="Appropriate and clear labelling on distribution and cabling?") # First Distro - 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_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
(if required)") - fd_earth_fault = models.IntegerField(blank=True,null=True,verbose_name="Earth Fault Loop Impedance", help_text="Earth Fault Loop Impedance (ZS)") - fd_pssc = models.IntegerField(blank=True,null=True,verbose_name="PSCC", help_text="Prospective Short Circuit Current") - #Worst case points - 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_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 (ZS)") - 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_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 (ZS)") - 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_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 (ZS)") + 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_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
(if required)") + fd_earth_fault = models.IntegerField(blank=True, null=True, verbose_name="Earth Fault Loop Impedance", help_text="Earth Fault Loop Impedance (ZS)") + fd_pssc = models.IntegerField(blank=True, null=True, verbose_name="PSCC", help_text="Prospective Short Circuit Current") + # Worst case points + 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_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 (ZS)") + 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_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 (ZS)") + 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_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 (ZS)") - all_rcds_tested = models.BooleanField(blank=True,null=True,help_text="All circuit RCDs tested?
(using test button)") - public_sockets_tested = models.BooleanField(blank=True,null=True,help_text="Public/Performer accessible circuits tested?
(using socket tester)") + all_rcds_tested = models.BooleanField(blank=True, null=True, help_text="All circuit RCDs tested?
(using test button)") + public_sockets_tested = models.BooleanField(blank=True, null=True, help_text="Public/Performer accessible circuits tested?
(using socket tester)") reviewed_at = models.DateTimeField(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): 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' - 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' 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' - 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' if errdict != {}: # If there was an error when validation diff --git a/RIGS/templates/rigboard.html b/RIGS/templates/rigboard.html index 824d9864..9bc3deec 100644 --- a/RIGS/templates/rigboard.html +++ b/RIGS/templates/rigboard.html @@ -8,6 +8,7 @@ New {% endif %} +

Key: ReadyAction RequiredCancelledNon-Rig

{% include 'event_table.html' %} {% endblock %} diff --git a/RIGS/templatetags/filters.py b/RIGS/templatetags/filters.py index 5f4177fe..d7e4bcf2 100644 --- a/RIGS/templatetags/filters.py +++ b/RIGS/templatetags/filters.py @@ -166,6 +166,7 @@ def yesnoi(boolean, invert=False, autoescape=True): value += ' ' return mark_safe(value) + @register.filter def title_spaced(string): return title(string).replace('_', ' ') diff --git a/RIGS/tests/test_functional.py b/RIGS/tests/test_functional.py index c1094bda..a54a0370 100644 --- a/RIGS/tests/test_functional.py +++ b/RIGS/tests/test_functional.py @@ -393,7 +393,7 @@ class TestEventDuplicate(BaseRigboardTest): self.assertEqual(newEvent.auth_request_by, 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("Event data duplicated but not yet saved", self.page.warning) # Check info message not visible diff --git a/RIGS/tests/test_models.py b/RIGS/tests/test_models.py index f6b7c8b4..2db6b2d9 100644 --- a/RIGS/tests/test_models.py +++ b/RIGS/tests/test_models.py @@ -101,8 +101,8 @@ class EventTestCase(TestCase): self.assertEqual(models.Event.objects.count(), 18, "Incorrect number of events, check setup") def test_rig_count(self): - # by my count this is 7 - self.assertEqual(models.Event.objects.rig_count(), 8) + # Changed to not include unreturned dry hires in rig count + self.assertEqual(models.Event.objects.rig_count(), 7) def test_current_events(self): current_events = models.Event.objects.current_events() @@ -374,8 +374,8 @@ class EventAuthorisationTestCase(TestCase): is_superuser=True # lazily grant all permissions )[0] self.person = models.Person.objects.create(name='Authorisation Test Person') - self.organisation = models.Organisation.objects.create(name='Authorisation Test Organisation') - self.event = models.Event.objects.create(name="AuthorisationTestCase", person=self.person, + self.organisation = models.Organisation.objects.create(name='Authorisation Test Organisation', union_account=True) + self.event = models.Event.objects.create(name="AuthorisationTestCase", person=self.person, organisation=self.organisation, start_date=date.today()) # Add some items models.EventItem.objects.create(event=self.event, name="Authorisation test item", quantity=2, cost=123.45, diff --git a/assets/tests/test_assets.py b/assets/tests/test_assets.py index 0e12a6f2..c20c372f 100644 --- a/assets/tests/test_assets.py +++ b/assets/tests/test_assets.py @@ -592,7 +592,7 @@ class TestVersioningViews(TestCase): self.assertEqual(response.status_code, 200) 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) self.assertEqual(response.status_code, 200) diff --git a/versioning/versioning.py b/versioning/versioning.py index 3d861070..c6afcbae 100644 --- a/versioning/versioning.py +++ b/versioning/versioning.py @@ -118,7 +118,7 @@ class ModelComparison(object): @cached_property 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) 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)