Skip to content

Commit

Permalink
Merge branch 'dbca-wa:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
NishantPhour authored Dec 30, 2024
2 parents 11f922e + 6739958 commit f58d37c
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions mooringlicensing/components/approvals/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ def create(self, request, *args, **kwargs):
if email_address and email_address_confirmation:
if email_address == email_address_confirmation:
if skipper:
this_user = EmailUser.objects.filter(email__iexact=email_address, is_active=True)
this_user = EmailUser.objects.filter(email__iexact=email_address, is_active=True).order_by('-id')
if this_user:
new_user = this_user.first()
else:
Expand Down Expand Up @@ -1006,7 +1006,7 @@ def create(self, request, *args, **kwargs):
if email_address and email_address_confirmation:
if email_address == email_address_confirmation:
if skipper:
this_user = EmailUser.objects.filter(email__iexact=email_address, is_active=True)
this_user = EmailUser.objects.filter(email__iexact=email_address, is_active=True).order_by('-id')
if this_user:
new_user = this_user.first()
else:
Expand Down
14 changes: 7 additions & 7 deletions mooringlicensing/components/approvals/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def send_auth_user_mooring_removed_notification(approval, mooring_licence):
if msg:
sender = settings.DEFAULT_FROM_EMAIL
try:
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None

Expand Down Expand Up @@ -142,7 +142,7 @@ def send_approval_expire_email_notification(approval):
if msg:
sender = settings.DEFAULT_FROM_EMAIL
try:
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None

Expand Down Expand Up @@ -172,7 +172,7 @@ def send_approval_cancelled_due_to_no_vessels_nominated_mail(approval, request=N

sender = settings.DEFAULT_FROM_EMAIL
try:
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None

Expand Down Expand Up @@ -209,7 +209,7 @@ def send_vessel_nomination_reminder_mail(approval, request=None):

sender = settings.DEFAULT_FROM_EMAIL
try:
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None

Expand Down Expand Up @@ -464,7 +464,7 @@ def send_approval_cancel_email_notification(approval):
}
sender = settings.DEFAULT_FROM_EMAIL
try:
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None
all_ccs = []
Expand Down Expand Up @@ -504,7 +504,7 @@ def send_approval_suspend_email_notification(approval, request=None):
}
sender = settings.DEFAULT_FROM_EMAIL
try:
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None
all_ccs = []
Expand Down Expand Up @@ -549,7 +549,7 @@ def send_approval_surrender_email_notification(approval, request=None, already_s
}
sender = settings.DEFAULT_FROM_EMAIL
try:
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None
all_ccs = []
Expand Down
8 changes: 4 additions & 4 deletions mooringlicensing/components/compliances/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def send_reminder_email_notification(compliance, is_test=False):
if msg:
sender = settings.DEFAULT_FROM_EMAIL
try:
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None

Expand All @@ -141,7 +141,7 @@ def send_internal_reminder_email_notification(compliance, is_test=False):
if msg:
sender = settings.DEFAULT_FROM_EMAIL
try:
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None

Expand Down Expand Up @@ -171,7 +171,7 @@ def send_due_email_notification(compliance, is_test=False):
if msg:
sender = settings.DEFAULT_FROM_EMAIL
try:
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None

Expand Down Expand Up @@ -199,7 +199,7 @@ def send_internal_due_email_notification(compliance, is_test=False):
if msg:
sender = settings.DEFAULT_FROM_EMAIL
try:
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None
_log_compliance_email(msg, compliance, sender=sender_user)
Expand Down
2 changes: 1 addition & 1 deletion mooringlicensing/components/emails/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def get_user_as_email_user(sender):
try:
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None
return sender_user
Expand Down
12 changes: 6 additions & 6 deletions mooringlicensing/components/proposals/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

def log_proposal_email(msg, proposal, sender, attachments=[]):
try:
sender_user = sender if isinstance(sender, EmailUser) else EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = sender if isinstance(sender, EmailUser) else EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None

Expand Down Expand Up @@ -256,7 +256,7 @@ def send_create_mooring_licence_application_email_notification(request, waiting_
}
sender = settings.DEFAULT_FROM_EMAIL
try:
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None

Expand Down Expand Up @@ -392,7 +392,7 @@ def send_invitee_reminder_email(approval, due_date, request=None):

sender = settings.DEFAULT_FROM_EMAIL
try:
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None

Expand Down Expand Up @@ -640,7 +640,7 @@ def send_endorser_reminder_email(proposal, request=None):
msgs = []
for site_licensee_mooring in proposal.site_licensee_mooring_request.filter(enabled=True,endorser_reminder_sent=False):
try:
endorser = EmailUser.objects.filter(email__iexact=site_licensee_mooring.site_licensee_email, is_active=True).first()
endorser = EmailUser.objects.filter(email__iexact=site_licensee_mooring.site_licensee_email, is_active=True).order_by('-id').first()
except:
# Should not reach here
continue
Expand Down Expand Up @@ -707,7 +707,7 @@ def send_approval_renewal_email_notification(approval):

sender = settings.DEFAULT_FROM_EMAIL
try:
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).first()
sender_user = EmailUser.objects.filter(email__iexact=sender, is_active=True).order_by('-id').first()
except:
sender_user = None

Expand Down Expand Up @@ -1600,7 +1600,7 @@ def send_endorsement_of_authorised_user_application_email(request, proposal):
for site_licensee_mooring_request in proposal.site_licensee_mooring_request.filter(enabled=True,declined_by_endorser=False,approved_by_endorser=False):
#replace with multiple site licensee emails
try:
endorser = EmailUser.objects.filter(email__iexact=site_licensee_mooring_request.site_licensee_email, is_active=True).first()
endorser = EmailUser.objects.filter(email__iexact=site_licensee_mooring_request.site_licensee_email, is_active=True).order_by('-id').first()
except:
# Should not reach here
return
Expand Down
2 changes: 1 addition & 1 deletion mooringlicensing/components/proposals/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ def update_proposal_applicant(proposal, request):
proposal_applicant.email = proposal_applicant_data['email']
try:
if proposal_applicant.email:
email_user = EmailUserRO.objects.filter(email__iexact=proposal_applicant.email, is_active=True).first()
email_user = EmailUserRO.objects.filter(email__iexact=proposal_applicant.email, is_active=True).order_by('-id').first()
proposal_applicant.email_user_id = email_user.id
except:
proposal_applicant.email_user_id = None
Expand Down
2 changes: 1 addition & 1 deletion mooringlicensing/components/users/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_or_create_system_user(email_user_id, email, first_name, last_name, dob,
system_user.save()
return system_user, False
else:
if EmailUserRO.objects.filter(id=email_user_id, is_active=True).exists():
if EmailUserRO.objects.filter(id=email_user_id, is_active=True).order_by('-id').exists():
try:
system_user = SystemUser.objects.create(
ledger_id_id=email_user_id,
Expand Down
16 changes: 8 additions & 8 deletions mooringlicensing/utils/mooring_licence_migrate_pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from mooringlicensing.components.users.utils import (
create_system_user, get_or_create_system_user,
get_user_name, get_or_create_system_user_address,
)
)

from mooringlicensing.components.proposals.models import (
Proposal,
Expand Down Expand Up @@ -997,7 +997,7 @@ def try_except(value):
self.no_email.append(user_row.pers_no)
continue

users = EmailUser.objects.filter(email__iexact=email, is_active=True)
users = EmailUser.objects.filter(email__iexact=email, is_active=True).order_by('-id')
if users.count() == 0:
print(f'wl - email not found: {email}')

Expand Down Expand Up @@ -1146,7 +1146,7 @@ def create_mooring_licences(self):
self.no_email.append(user_row.pers_no)
continue

users = EmailUser.objects.filter(email__iexact=email, is_active=True)
users = EmailUser.objects.filter(email__iexact=email, is_active=True).order_by('-id')
if users.count() == 0:
print(f'ml - email not found: {email}')

Expand Down Expand Up @@ -1393,7 +1393,7 @@ def create_authuser_permits(self):
continue

try:
licensee = EmailUser.objects.filter(email__iexact=email_l.lower(), is_active=True).first()
licensee = EmailUser.objects.filter(email__iexact=email_l.lower(), is_active=True).order_by('-id').first()
except Exception as e:
errors.append("Rego No " + str(rego_no) + ": Licensee with email " + str(email_l.lower()) + " does not exist")
continue
Expand All @@ -1409,7 +1409,7 @@ def create_authuser_permits(self):
continue

try:
user = EmailUser.objects.filter(email__iexact=email_u.lower(), is_active=True).first()
user = EmailUser.objects.filter(email__iexact=email_u.lower(), is_active=True).order_by('-id').first()
except Exception as e:
errors.append("Rego No " + str(rego_no) + ": User with email " + str(email_u.lower()) + " does not exist")
continue
Expand Down Expand Up @@ -1632,7 +1632,7 @@ def create_waiting_list(self):
first_name = row.first_name.lower().title().strip()
last_name = row.last_name.lower().title().strip()
try:
user = EmailUser.objects.filter(email__iexact=email.lower(), is_active=True).first()
user = EmailUser.objects.filter(email__iexact=email.lower(), is_active=True).order_by('-id').first()
except Exception as e:
errors.append("Rego No " + str(rego_no) + " - User Id " + str(user.id) + ": User with email " + str(email.lower()) + " does not exist")
continue
Expand Down Expand Up @@ -1797,7 +1797,7 @@ def create_dcv(self):
first_name = row.first_name.lower().title().strip()
last_name = row.last_name.lower().title().strip()
try:
user = EmailUser.objects.filter(email__iexact=email.lower(), is_active=True).first()
user = EmailUser.objects.filter(email__iexact=email.lower(), is_active=True).order_by('-id').first()
user.first_name = first_name
user.last_name = last_name
user.save()
Expand Down Expand Up @@ -1980,7 +1980,7 @@ def create_annual_admissions(self):
vessel_length = row['vessel_length']

try:
user = EmailUser.objects.filter(email__iexact=email.lower().strip(), is_active=True).first()
user = EmailUser.objects.filter(email__iexact=email.lower().strip(), is_active=True).order_by('-id').first()
except Exception as e:
errors.append("User with email " + str(email.lower()) + " does not exist")
continue
Expand Down

0 comments on commit f58d37c

Please sign in to comment.