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

Bulkimport #11779

Merged
merged 8 commits into from
Feb 23, 2024
Merged

Bulkimport #11779

merged 8 commits into from
Feb 23, 2024

Conversation

nick2432
Copy link
Contributor

@nick2432 nick2432 commented Jan 24, 2024

Summary

Description of the Change:
The proposed changes aim to enhance the user creation process in the FacilityUserManager class by addressing issues related to case-insensitive username matching and the verification of duplicate usernames during bulk user imports.
Case-Insensitive Username Matching (FacilityUserManager):

In the create_user function of the FacilityUserManager class, case sensitivity is introduced to the username matching process. This ensures that usernames are checked in a case-sensitive manner during user creation.
Link to the relevant code: [FacilityUserManager]
Bulk User Import Duplicate Username Check (bulkimportusers.py):
Previously, the bulk import code only checked for username clashes if a UUID was specified for the user. The proposed changes extend this check to cases where the UUID is not specified, providing a more comprehensive verification process.

References

Fixes #11081

@github-actions github-actions bot added DEV: backend Python, databases, networking, filesystem... SIZE: small labels Jan 24, 2024
@rtibbles rtibbles self-assigned this Jan 26, 2024
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

2 changes needed, to have consistent case insensitivity.

@@ -639,7 +639,7 @@ def create_user(self, username, email=None, password=None, **extra_fields):
if extra_fields.get("facility") is None:
extra_fields["facility"] = Facility.get_default_facility()
if self.filter(
username__iexact=username, facility=extra_fields["facility"]
username=username, facility=extra_fields["facility"]
Copy link
Member

Choose a reason for hiding this comment

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

This should not be updated - the intention was for the bulk import flow to match the enforcement that happens here, not for this enforcement to be removed.

# If UUID is not specified, check for a username clash
if values["uuid"] == "":
existing_user = FacilityUser.objects.filter(
username=user, facility=self.default_facility
Copy link
Member

Choose a reason for hiding this comment

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

We should do a case insensitive match here as well, to parallel the changes you made above.

@nick2432
Copy link
Contributor Author

@rtibbles I have changed what you said.

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

Excellent, this looks good. We'll have manual QA test this, but I think this should be mergeable soon.

We will hold off on merging it until the 0.16.0 release is out.

In the meantime, could you address the linting issue? For now we can ignore the complexity requirement by doing this:

def build_users_objects(self, users):  # noqa C901

This is a directive comment to our linter to ignore this rule for this function for now.

@rtibbles rtibbles added this to the Kolibri 0.16: Planned Patch 1 milestone Feb 1, 2024
@nick2432
Copy link
Contributor Author

@rtibbles , do you have an estimate for when this will be merged?

@rtibbles
Copy link
Member

After 0.16.0 is released! We're in the final stages of QA now, and made a release candidate yesterday, so it is close :)

@pcenov
Copy link
Member

pcenov commented Feb 15, 2024

Hi @nick2432 and @rtibbles - I confirm that it's no longer possible to import a duplicate username (regardless of the letter case) if it's already extant in the facility.
However if there are several duplicate usernames in the CSV file (with different letter case like Peter, PETER) and I am importing them for the first time it's still possible to import all of them. So the question is whether this is in scope for this PR and should be fixed as well?

2024-02-15_18-21-57.mp4

@rtibbles
Copy link
Member

That's a good catch, Peter - I think we can file that as a follow up issue for now, so as not to block @nick2432 further here, but very happy for him to pick it up if he's interested!

@nick2432
Copy link
Contributor Author

Thank you for the clarification, @rtibbles . I'll proceed with the current PR as suggested. I'll make a note of the additional issue with importing several duplicate usernames and will file it as a follow-up task. If there are any specific considerations or details I should be aware of while working on the current PR, please let me know. Appreciate your guidance!

@pcenov
Copy link
Member

pcenov commented Feb 16, 2024

Hi @nick2432 I have filed the follow-up issue here: #11890
I didn't observe any other issues while manually testing so if you are not going to be making any other changes here we could go ahead and approve this PR.

@nick2432
Copy link
Contributor Author

Hi @nick2432 I have filed the follow-up issue here: #11890 I didn't observe any other issues while manually testing so if you are not going to be making any other changes here we could go ahead and approve this PR.

ok

Copy link
Member

@radinamatic radinamatic left a comment

Choose a reason for hiding this comment

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

Manual QA passed, with one follow-up issue opened, good to go! 💯 🚀 :shipit:

@rtibbles rtibbles merged commit 0f802b0 into learningequality:release-v0.16.x Feb 23, 2024
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem... SIZE: small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User bulk import does not prevent case insensitive username matches
4 participants