-
Notifications
You must be signed in to change notification settings - Fork 2
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
Adds username normalization #627
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor comment
users/models_test.py
Outdated
|
||
|
||
@pytest.mark.django_db | ||
def test_username_normalization(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a duplicate of the test in the api.py? Is this test incomplete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed in ea43e81 - this was old and got left by mistake
…ions that will autopopulate said field
…tions to wrap up username normalization
d29cc60
to
ea43e81
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@jkachel can you remind me why you put this on hold? Would this have avoided the situation in https://odl.zendesk.com/agent/tickets/139242 and https://sentry.io/organizations/mit-office-of-digital-learning/issues/2616447470/events/9ab540c0d80f4983933e71bb7b9cd728/?project=5864687 |
This was put on hold because it needed some coordination to do - there was a part to this that was normalizing the existing usernames in the database. (See #259 (comment)) This was done about the time Brian left, though; I was going to get him to help with that. Otherwise, the code worked and it would have caught this, I think. It'd need some revising to work in the current version of the app before we could deploy it now. |
cb0209b
to
d808f52
Compare
Pre-Flight checklist
What are the relevant tickets?
#259
What's this PR do?
Fixes #259.
This adds a
normalized_username
field to the users model and an API function to perform the normalization. It also updates the openedxcreate_edx_user
call to pass thenormalized_username
field instead of the regularusername
field.How should this be manually tested?
The migrations to add the
normalized_username
field will automatically normalize the usernames. Because of that, it's pretty important that your user database does not contain accounts that will conflict. (Per #259, thenormalized_username
field is uniqued.) There is a management command to check for and fix usernames that would conflict that's in PR #629.After performing the migrations, create a user with a username using accented characters (áüô, etc.). The username should be created on the Open edX side with those characters converted to non-accented characters (auo, etc.).
Some characters will not be normalized and will instead be dropped. This includes ø so testing with that character will result in a normalized username without that character (for example, Søren will normalize to Sren).