IA-4360: Make import of users in bulk easier#2701
Open
Conversation
f50671f to
0c78246
Compare
628268f to
986392b
Compare
quang-le
requested changes
Feb 12, 2026
Comment on lines
361
to
364
| email = data.get("email", "").strip() if data.get("email") else None | ||
| if email: | ||
| if email in existing_emails: | ||
| row_errors["email"] = f"Email '{email}' already exists" |
Member
There was a problem hiding this comment.
Emails can be reused across users (eg: multi-account users), so this should not be considered an error
Comment on lines
371
to
373
| dhis2_id = data.get("dhis2_id", "").strip() if data.get("dhis2_id") else None | ||
| if dhis2_id and dhis2_id in existing_dhis2_ids: | ||
| row_errors["dhis2_id"] = f"DHIS2 ID '{dhis2_id}' already exists" |
Comment on lines
+48
to
+52
| default_permissions = serializers.ListField(child=serializers.IntegerField(), write_only=True, required=False) | ||
| default_projects = serializers.ListField(child=serializers.IntegerField(), write_only=True, required=False) | ||
| default_user_roles = serializers.ListField(child=serializers.IntegerField(), write_only=True, required=False) | ||
| default_org_units = serializers.ListField(child=serializers.IntegerField(), write_only=True, required=False) | ||
| default_teams = serializers.ListField(child=serializers.IntegerField(), write_only=True, required=False) |
Member
There was a problem hiding this comment.
As discussed change the model and serializer to use foreign key/many to one relationships when possible
Contributor
Author
There was a problem hiding this comment.
many to many relationship are updated in model: https://github.com/BLSQ/iaso/pull/2701/changes/BASE..986392b5c5ec79998964ca4d208ea55c91e1f4d3#diff-8fb5b58193ea0350e70424248362015e84b5c750ae0193edb9ff2e0401619b01
and serializers receive a list of intgers
the only field that is still a CharField is the organization because it's directly attached to profile model
2e536af to
327ccdb
Compare
b06a502 to
5534790
Compare
45a8680 to
0942ab0
Compare
quang-le
approved these changes
Feb 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What problem is this PR solving?
Make user import csv in bulk, add optional default configuration for empty columns
Related JIRA tickets
IA-4360
Changes
How to test
I think the simplest way to test is to use the frontend branch (still in progress): https://github.com/BLSQ/iaso/tree/IA-4360-make-import-of-users-in-bulk-easier-front
1. Happy Path -
IA4360_happy_path.csvExpected Response:
200 OK{"Accounts created": 3}2. Email Invitation Only -
IA4360_email_invitation_only.csvExpected Response:
200 OK{"Accounts created": 3}(Email invitations sent in background task)
3. Validation Failures - [
IA4360_validation_failures.csv]https://bluesquare.atlassian.net/issues?jql=assignee%20%3D%20currentUser()%20AND%20project%3D%27IA%27%20AND%20statusCategory%20!%3D%203&selectedIssue=IA-4360Expected Response:
400 Bad Request{ "error": { "file": { "csv_validation_errors": [ {"row": 2, "errors": {"password": "This password is too short..."}}, {"row": 3, "errors": {"email": "Enter a valid email address."}}, {"row": 4, "errors": {"permissions": "Invalid permissions: non_existent_permission"}}, {"row": 5, "errors": {"projects": "Invalid projects: NonExistentProject"}}, {"row": 6, "errors": {"user_roles": "Invalid user roles: NonExistentRole"}}, {"row": 8, "errors": {"password": "Either password or email is required..."}}, {"row": 9, "errors": {"permissions": "Invalid permissions: fake_perm1, fake_perm2"}}, {"row": 10, "errors": {"projects": "Invalid projects: FakeProject1, FakeProject2"}}, {"row": 11, "errors": {"username": "This field may not be blank."}}, {"row": 12, "errors": {"teams": "Invalid teams: NonExistentTeam"}} ] } } }4. Password No Email -
IA4360_password_no_email.csvExpected Response:
200 OK{"Accounts created": 3}