Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,11 @@ def send_verification_expiry_email(self, batch_verifications, email_config):
return True

site = Site.objects.get_current()
baseUrl = settings.ACCOUNT_MICROFRONTEND_URL.rstrip('/')
Comment thread
holaontiveros marked this conversation as resolved.
Outdated
message_context = get_base_template_context(site)
message_context.update({
'platform_name': settings.PLATFORM_NAME,
'lms_verification_link': f'{settings.ACCOUNT_MICROFRONTEND_URL}/id-verification',
'lms_verification_link': f'{baseUrl}/id-verification',
'help_center_link': settings.ID_VERIFICATION_SUPPORT_LINK
})

Expand Down
3 changes: 2 additions & 1 deletion lms/djangoapps/verify_student/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ def get_verify_location(cls, course_id=None):
Returns a string:
Returns URL for IDV on Account Microfrontend
"""
location = f'{settings.ACCOUNT_MICROFRONTEND_URL}/id-verification'
baseUrl = settings.ACCOUNT_MICROFRONTEND_URL.rstrip('/')

Copilot AI Jun 6, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The same trailing-slash stripping logic is duplicated across multiple modules; consider extracting this into a shared helper function to improve maintainability.

Suggested change
baseUrl = settings.ACCOUNT_MICROFRONTEND_URL.rstrip('/')
baseUrl = strip_trailing_slash(settings.ACCOUNT_MICROFRONTEND_URL)

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean yeah but it's way better to address the problem in a more global way that probably doesn't even require using URLs as strings... 🤷‍♂️

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

way better to address the problem in a more global way that probably doesn't even require using URLs as strings

absolutely.

As long as we're handing these as strings, though, copilot's advice seems pretty bad? We all know what .rstrip('/') means, why hide it behind a function?

location = f'{baseUrl}/id-verification'
if course_id:
location += f'?course_id={quote(str(course_id))}'

Expand Down
3 changes: 2 additions & 1 deletion lms/djangoapps/verify_student/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,8 @@ def results_callback(request): # lint-amnesty, pylint: disable=too-many-stateme
log.info("[COSMO-184] Denied verification for receipt_id={receipt_id}.".format(receipt_id=receipt_id))

attempt.deny(json.dumps(reason), error_code=error_code)
reverify_url = f'{settings.ACCOUNT_MICROFRONTEND_URL}/id-verification'
baseUrl = settings.ACCOUNT_MICROFRONTEND_URL.rstrip('/')
reverify_url = f'{baseUrl}/id-verification'
verification_status_email_vars['reasons'] = reason
verification_status_email_vars['reverify_url'] = reverify_url
verification_status_email_vars['faq_url'] = settings.ID_VERIFICATION_SUPPORT_LINK
Expand Down
3 changes: 2 additions & 1 deletion openedx/core/djangoapps/notifications/email/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,14 @@ def create_email_template_context(username):
'channel': 'email',
'value': False
}
baseUrl = settings.ACCOUNT_MICROFRONTEND_URL.rstrip('/')
return {
"platform_name": settings.PLATFORM_NAME,
"mailing_address": settings.CONTACT_MAILING_ADDRESS,
"logo_url": get_logo_url_for_email(),
"logo_notification_cadence_url": settings.NOTIFICATION_DIGEST_LOGO,
"social_media": social_media_info,
"notification_settings_url": f"{settings.ACCOUNT_MICROFRONTEND_URL}/#notifications",
"notification_settings_url": f"{baseUrl}/#notifications",
"unsubscribe_url": get_unsubscribe_link(username, patch)
}

Expand Down