Skip to content

Commit

Permalink
Merge pull request #518 from awf-dbca/misc-fixes-7
Browse files Browse the repository at this point in the history
fixed vessel dimension validation for AUP
  • Loading branch information
xzzy authored Jan 15, 2025
2 parents 9dfa331 + 400e265 commit 0c3c214
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions mooringlicensing/components/proposals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1495,28 +1495,23 @@ def proposed_approval(self, request, details):
elif self.mooring_authorisation_preference == "site_licensee" and not True in requested_checked_list:
raise serializers.ValidationError("No mooring provided")


vessel_details = None
check_mooring_ids = id_list + requested_id_list
if self.vessel_ownership:
check_vessel = self.vessel_ownership.vessel
vessel_details = check_vessel.latest_vessel_details

check_moorings = MooringOnApproval.objects.filter(id__in=check_mooring_ids)

if mooring_id and vessel_details:
if (vessel_details.vessel_length > mooring.vessel_size_limit or
vessel_details.vessel_draft > mooring.vessel_draft_limit or
(vessel_details.vessel_weight > mooring.vessel_weight_limit and mooring.vessel_weight_limit > 0)):
if mooring_id:
if (self.vessel_length > mooring.vessel_size_limit or
self.vessel_draft > mooring.vessel_draft_limit or
(self.vessel_weight > mooring.vessel_weight_limit and mooring.vessel_weight_limit > 0)):
raise serializers.ValidationError("Vessel dimensions are not compatible with one or more moorings")

for i in check_moorings:
if not i.mooring:
raise serializers.ValidationError("Mooring does not exist")

if (vessel_details.vessel_length > i.mooring.vessel_size_limit or
vessel_details.vessel_draft > i.mooring.vessel_draft_limit or
(vessel_details.vessel_weight > i.mooring.vessel_weight_limit and i.mooring.vessel_weight_limit > 0)):
if (self.vessel_length > i.mooring.vessel_size_limit or
self.vessel_draft > i.mooring.vessel_draft_limit or
(self.vessel_weight > i.mooring.vessel_weight_limit and i.mooring.vessel_weight_limit > 0)):
raise serializers.ValidationError("Vessel dimensions are not compatible with one or more moorings")

if not mooring_id and not check_mooring_ids and self.application_type.code == "aua":
Expand Down

0 comments on commit 0c3c214

Please sign in to comment.