Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email query update #477

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions mooringlicensing/components/approvals/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,6 @@ def add_comms_log(self, request, *args, **kwargs):
class DcvAdmissionViewSet(viewsets.GenericViewSet, mixins.RetrieveModelMixin):
queryset = DcvAdmission.objects.all().order_by('id')
serializer_class = DcvAdmissionSerializer
permission_classes=[IsAuthenticated]

def get_queryset(self):
user = self.request.user
Expand Down Expand Up @@ -835,7 +834,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=email_address)
this_user = EmailUser.objects.filter(email__iexact=email_address)
if this_user:
new_user = this_user.first()
else:
Expand Down Expand Up @@ -962,7 +961,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=email_address)
this_user = EmailUser.objects.filter(email__iexact=email_address)
if this_user:
new_user = this_user.first()
else:
Expand Down
4 changes: 2 additions & 2 deletions mooringlicensing/components/proposals/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,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.get(email=site_licensee_mooring.site_licensee_email)
endorser = EmailUser.objects.get(email__iexact=site_licensee_mooring.site_licensee_email)
except:
# Should not reach here
continue
Expand Down Expand Up @@ -1432,7 +1432,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.get(email=site_licensee_mooring_request.site_licensee_email)
endorser = EmailUser.objects.get(email__iexact=site_licensee_mooring_request.site_licensee_email)
except:
# Should not reach here
return
Expand Down
2 changes: 1 addition & 1 deletion mooringlicensing/components/proposals/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ def get_site_licensee_moorings(self, obj):
checked = item['checked']

site_licensee = ""
site_licensee_system_user = su_qs.filter(email=i.site_licensee_email)
site_licensee_system_user = su_qs.filter(email__iexact=i.site_licensee_email)
if site_licensee_system_user.exists():
site_licensee = get_user_name(site_licensee_system_user.first())["full_name"]
endorsement = "Not Actioned"
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 @@ -874,7 +874,7 @@ def update_proposal_applicant(proposal, request):
proposal_applicant.email = proposal_applicant_data['email']
try:
if proposal_applicant.email:
email_user = EmailUserRO.objects.get(email=proposal_applicant.email)
email_user = EmailUserRO.objects.get(email__iexact=proposal_applicant.email)
proposal_applicant.email_user_id = email_user.id
except:
proposal_applicant.email_user_id = None
Expand Down
8 changes: 4 additions & 4 deletions mooringlicensing/utils/mooring_licence_migrate_pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ def try_except(value):
self.no_email.append(user_row.pers_no)
continue

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

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

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

Expand Down Expand Up @@ -1647,7 +1647,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.get(email=email.lower())
user = EmailUser.objects.get(email__iexact=email.lower())
user.first_name = first_name
user.last_name = last_name
user.save()
Expand Down Expand Up @@ -1810,7 +1810,7 @@ def create_annual_admissions(self):
vessel_length = row['vessel_length']

try:
user = EmailUser.objects.get(email=email.lower().strip())
user = EmailUser.objects.get(email__iexact=email.lower().strip())
except Exception as e:
errors.append("User with email " + str(email.lower()) + " does not exist")
continue
Expand Down
Loading