Skip to content

feat: Validate country input during student registration#37719

Open
Waleed-Mujahid wants to merge 2 commits into
openedx:masterfrom
edly-io:waleed/add-country-validation
Open

feat: Validate country input during student registration#37719
Waleed-Mujahid wants to merge 2 commits into
openedx:masterfrom
edly-io:waleed/add-country-validation

Conversation

@Waleed-Mujahid
Copy link
Copy Markdown
Contributor

Description

While using the CSV enroll option in LMS instructor tab if an instructor use full country name instead ISO country code a general DataError is raised which can be confusing for instructors.

Roadmap

openedx/platform-roadmap#487

Before

image

After

image

Testing instructions

  1. Set ALLOW_AUTOMATED_SIGNUPS as True in site configurations
  2. Open a course on LMS as instructor
  3. Click on Instructor tab
  4. Click on membership
  5. Upload a csv with fields in correct order
  6. For country give value in Non-ISO code format
  7. A verbose error will be returned instead of a general DataError

@Waleed-Mujahid
Copy link
Copy Markdown
Contributor Author

@mphilbrick211 Hey can you look into this PR and the linked issue

@mphilbrick211
Copy link
Copy Markdown

Hi @Waleed-Mujahid! Is this currently for a product proposal that's in progress? It might be that the Product team has not had a chance to review yet.

@mphilbrick211 mphilbrick211 moved this from Needs Triage to Product Review in Contributions Dec 9, 2025
@mphilbrick211 mphilbrick211 added the product review PR requires product review before merging label Dec 9, 2025
@Waleed-Mujahid Waleed-Mujahid force-pushed the waleed/add-country-validation branch from b04edbc to 2d03325 Compare December 29, 2025 15:10
Added validation to ensure that the country code provided during student registration is valid. If the country code is invalid, an error message is appended to the row errors for appropriate feedback.
@Waleed-Mujahid Waleed-Mujahid force-pushed the waleed/add-country-validation branch from 2d03325 to f7bca07 Compare December 29, 2025 15:12
@Waleed-Mujahid
Copy link
Copy Markdown
Contributor Author

@mphilbrick211 hey the product review is complete. Can you ask someone to review this?

@ayub02
Copy link
Copy Markdown
Contributor

ayub02 commented Dec 31, 2025

I agree with this change. Also commented with my approval on related issue: openedx/platform-roadmap#487

@mphilbrick211 mphilbrick211 added product review complete PR has gone through product review and removed product review PR requires product review before merging labels Jan 5, 2026
@mphilbrick211 mphilbrick211 moved this from Product Review to Ready for Review in Contributions Jan 5, 2026
@mphilbrick211 mphilbrick211 added the needs reviewer assigned PR needs to be (re-)assigned a new reviewer label Jan 5, 2026
cohort_name = None
course_mode = None

if not Country(country).name:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We're not eliminating spaces in the country; something like " US" is failing.

Suggested change
if not Country(country).name:
if not Country(country.strip()).name:

cohort_name = None
course_mode = None

if not Country(country).name:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Before these changes, for an existing user (only for enrollment), the country column wasn't used. But now it's checked, and this can generate errors. Can you only perform this check for new users? This would make it backward compatible.

@ChrisChV ChrisChV self-assigned this May 30, 2026
@ChrisChV
Copy link
Copy Markdown
Contributor

Before the changes, users could be created with an empty country code; now, the new checks generate an error.

image

@ChrisChV
Copy link
Copy Markdown
Contributor

Hi @Waleed-Mujahid, nice work! I've left some comments. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs reviewer assigned PR needs to be (re-)assigned a new reviewer product review complete PR has gone through product review

Projects

Status: Ready for Review

Development

Successfully merging this pull request may close these issues.

4 participants