From 258cac061b35b8c75ce0974edd2e63714f2a2598 Mon Sep 17 00:00:00 2001 From: Ashley Date: Wed, 9 Oct 2024 07:15:57 +0000 Subject: [PATCH 1/2] Update: error handling for missing bay ids and fixed checking update status --- mooringlicensing/components/main/utils.py | 30 +++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/mooringlicensing/components/main/utils.py b/mooringlicensing/components/main/utils.py index 776cc9eb8..080d71434 100755 --- a/mooringlicensing/components/main/utils.py +++ b/mooringlicensing/components/main/utils.py @@ -128,10 +128,13 @@ def retrieve_mooring_areas(): orig_mo = deepcopy(mo) mo.mooring_bookings_id=mooring.get("id") mo.name=mooring.get("name") - mo.mooring_bay = MooringBay.objects.get( - mooring_bookings_id=mooring.get('marine_park_id'), + try: + mo.mooring_bay = MooringBay.objects.get( + mooring_bookings_id=mooring.get('marine_park_id'), active=True - ) + ) + except: + continue mo.vessel_size_limit = mooring.get('vessel_size_limit') mo.vessel_draft_limit = mooring.get('vessel_draft_limit') mo.vessel_beam_limit = mooring.get('vessel_beam_limit') @@ -139,16 +142,27 @@ def retrieve_mooring_areas(): mo.mooring_bookings_mooring_specification = mooring.get('mooring_specification') mo.mooring_bookings_bay_id = mooring.get('marine_park_id') mo.save() - if orig_mo != mo: + + if (float(mo.vessel_size_limit) != float(orig_mo.vessel_size_limit) or + float(mo.vessel_draft_limit) != float(orig_mo.vessel_draft_limit) or + float(mo.vessel_beam_limit) != float(orig_mo.vessel_beam_limit) or + float(mo.vessel_weight_limit) != float(orig_mo.vessel_weight_limit) or + float(mo.mooring_bookings_mooring_specification) != float(orig_mo.mooring_bookings_mooring_specification) or + float(mo.mooring_bookings_bay_id) != float(orig_mo.mooring_bookings_bay_id)): records_updated.append(str(mo.name)) else: + try: + mooring_bay = MooringBay.objects.get( + mooring_bookings_id=mooring.get('marine_park_id'), + active=True + ) + except: + continue + mooring = Mooring.objects.create( mooring_bookings_id=mooring.get("id"), name=mooring.get("name"), - mooring_bay = MooringBay.objects.get( - mooring_bookings_id=mooring.get('marine_park_id'), - active=True - ), + mooring_bay = mooring_bay, vessel_size_limit = mooring.get('vessel_size_limit'), vessel_draft_limit = mooring.get('vessel_draft_limit'), vessel_beam_limit = mooring.get('vessel_beam_limit'), From 34ab3b1744dac05d85f5d145f468374c3a35e3d0 Mon Sep 17 00:00:00 2001 From: Ashley Date: Wed, 9 Oct 2024 08:31:19 +0000 Subject: [PATCH 2/2] Update: removed mooring on approval model from mooring reversion follow list - was causing save error for moorings --- mooringlicensing/components/proposals/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mooringlicensing/components/proposals/models.py b/mooringlicensing/components/proposals/models.py index 957dc233d..bd203852c 100644 --- a/mooringlicensing/components/proposals/models.py +++ b/mooringlicensing/components/proposals/models.py @@ -5752,7 +5752,7 @@ class Meta: reversion.register(ProposalLogDocument, follow=[]) reversion.register(ProposalLogEntry, follow=['documents']) reversion.register(MooringBay, follow=['proposal_set', 'mooring_set']) -reversion.register(Mooring, follow=['ria_generated_proposal', 'comms_logs', 'action_logs', 'mooringonapproval_set', 'approval_set']) +reversion.register(Mooring, follow=['ria_generated_proposal', 'comms_logs', 'action_logs', 'approval_set']) reversion.register(MooringLogDocument, follow=[]) reversion.register(MooringLogEntry, follow=['documents']) reversion.register(MooringUserAction, follow=[])