Skip to content

Commit

Permalink
Merge pull request #541 from awf-dbca/wla-auto-approve
Browse files Browse the repository at this point in the history
Wla auto approve
  • Loading branch information
preranaandure authored Feb 18, 2025
2 parents 3328a57 + 71e1a62 commit 327bbc5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions mooringlicensing/components/proposals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2365,7 +2365,7 @@ def keeping_current_vessel(self):
#however, no such check is required to determine if the vessel is being kept or not -
# we just need to check if the proposal's vessel registration is the same or not

if self.code == 'mla':
if self.application_type_code == 'mla':
from mooringlicensing.components.approvals.models import VesselOwnershipOnApproval
#account for multiple vessel ownerships
previous_ownerships = None
Expand All @@ -2380,15 +2380,14 @@ def keeping_current_vessel(self):
else:
previous_rego_no = None
if (self.previous_application and
self.previous_application and
self.previous_application.vessel_details and
self.previous_application.vessel_details.vessel and
self.previous_application.vessel_ownership and
not self.previous_application.vessel_ownership.end_date): #end_date means sold
previous_rego_no = self.previous_application.vessel_details.vessel.rego_no

if(previous_rego_no and self.vessel_details and self.vessel_details.vessel and
previous_rego_no == self.vessel_details.vessel.rego_no):
if(previous_rego_no and
previous_rego_no == self.rego_no):
return True

return False
Expand All @@ -2397,7 +2396,7 @@ def vessel_ownership_changed(self):

previous_ownership = None

if self.code == 'mla':
if self.application_type_code == 'mla':
from mooringlicensing.components.approvals.models import VesselOwnershipOnApproval
#account for multiple vessel ownerships
previous_ownerships = None
Expand Down Expand Up @@ -2660,11 +2659,11 @@ def set_auto_approve(self,request):
self.proposal_applicant.email_user_id == request.user.id)
):

if not self.vessel_on_proposal() and not self.mooring_preference_changed() and not self.vessel_details:
if not self.vessel_on_proposal() and not self.mooring_preference_changed() and not self.rego_no:
self.auto_approve = True
self.save()
elif (
(not self.vessel_on_proposal() and self.vessel_details and self.vessel_details.vessel) or
(not self.vessel_on_proposal() and self.rego_no) or
self.mooring_preference_changed() or
self.has_higher_vessel_category() or
not self.vessel_moorings_compatible() or
Expand Down
2 changes: 1 addition & 1 deletion mooringlicensing/utils/mooring_licence_migrate_pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,7 @@ def create_authuser_permits(self):
mooring = Mooring.objects.filter(name=auth_user.mooring_no)

#ensure the mooring is licensed
if mooring.first().mooring_licence:
if mooring.exists() and mooring.first().mooring_licence:
site_licensee = auth_user.licencee_approved == 'Y'
moa = MooringOnApproval.objects.create(
approval=approval,
Expand Down

0 comments on commit 327bbc5

Please sign in to comment.