fix: allow course staff role to be updated with email change #321
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
JIRA: COSMO-478
Description:
If a user is added to a course with either staff or instructor permissions, changes their email, and then is added to another course as staff or instructor, the second event meant to sync staff role permissions with edx-exams will fail due to an integrity/unique constraint error. This is because the call to get or create a new
User
object in the event handler is keyed off of both theusername
andemail
fields, which means that subsequent email changes will result in calls to create a newUser
object with the sameusername
but newemail
, as opposed to just getting the existingUser
object.This bug is fixed by only using the
username
field to get or create a newUser
object.Merge checklist:
Post merge: