Skip to content

Commit

Permalink
Update: renewal notice changes are saved individually not via qs
Browse files Browse the repository at this point in the history
  • Loading branch information
awf-dbca committed Dec 12, 2024
1 parent 2004a1e commit fc4015a
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions mooringlicensing/management/commands/approval_renewal_notices.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,24 @@ def perform_per_type(self, number_of_days_code, approval_class, updates, errors)
for a in approvals:
try:
if not approval_class == DcvPermit:
v_details = a.current_proposal.latest_vessel_details
v_ownership = a.current_proposal.vessel_ownership
if (not v_details or v_ownership.end_date) and a.code in [AnnualAdmissionPermit.code, AuthorisedUserPermit.code,]:
approval = Approval.objects.get(id=a.id)
v_details = approval.current_proposal.latest_vessel_details
v_ownership = approval.current_proposal.vessel_ownership
if (not v_details or v_ownership.end_date) and approval.code in [AnnualAdmissionPermit.code, AuthorisedUserPermit.code,]:
# Null vessel is not allowed for both the annual admission permit application and authorised user permit application.
continue
else:
a.generate_renewal_doc()
logger.info(f'Renewal document has been generated for the approval: [{a}]')

send_approval_renewal_email_notification(a)
a.renewal_sent = True
a.save()

a.log_user_action(ApprovalUserAction.ACTION_RENEWAL_NOTICE_SENT_FOR_APPROVAL.format(a),)
logger.info(ApprovalUserAction.ACTION_RENEWAL_NOTICE_SENT_FOR_APPROVAL.format(a))
updates.append(a.lodgement_number)
approval.generate_renewal_doc()
logger.info(f'Renewal document has been generated for the approval: [{approval}]')
else:
approval = DcvPermit.objects.get(id=a.id)
send_approval_renewal_email_notification(approval)
approval.renewal_sent = True
approval.save()

approval.log_user_action(ApprovalUserAction.ACTION_RENEWAL_NOTICE_SENT_FOR_APPROVAL.format(approval),)
logger.info(ApprovalUserAction.ACTION_RENEWAL_NOTICE_SENT_FOR_APPROVAL.format(approval))
updates.append(approval.lodgement_number)
except Exception as e:
err_msg = 'Error sending renewal notice for Approval {} - Error {}'.format(a.lodgement_number, str(e))
logger.error(err_msg)
Expand Down

0 comments on commit fc4015a

Please sign in to comment.