-
Notifications
You must be signed in to change notification settings - Fork 519
✨(backend) manage reconciliation requests for user accounts #1708
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
base: main
Are you sure you want to change the base?
Conversation
4d4bd60 to
ab55e01
Compare
35c4d49 to
5090839
Compare
47099e1 to
57050a1
Compare
| reader = csv.DictReader(f) | ||
| rec_entries_created = 0 | ||
| for row in reader: | ||
| status = row["status"] |
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.
Maybe I'm wrong, but this column status is useless, don't you think? You can accept only one value. Or perhaps I'm not understanding its purpose.
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.
|
|
||
| self.logs += f"""Requested update for {len(updated_accesses)} DocumentAccess items | ||
| and deletion for {len(removed_accesses)} DocumentAccess items.\n""" | ||
| self.status = "done" |
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.
Changing the status can lead to an unwanted state if something wrong happens between when this function is executed and when the bulk update is made.
src/backend/core/models.py
Outdated
| blank=True, | ||
| related_name="inactive_user", | ||
| ) | ||
| active_confirmation_id = models.UUIDField( |
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.
It's a little bit long, but active_email_confirmation_id gives probably more information.
src/backend/core/models.py
Outdated
| active_confirmation_id = models.UUIDField( | ||
| default=uuid.uuid4, unique=True, editable=False, null=True | ||
| ) | ||
| inactive_confirmation_id = models.UUIDField( |
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.
Same here
| You can submit another request with the valid email addresses. | ||
| """ | ||
| ).format(email1=email_1, email2=email_2), | ||
| "link": f"{domain}/", | ||
| "link_label": str(_("Click here")), | ||
| "button_label": str(_("Make a new request")), |
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.
I can see there is a button to trigger a new request, is there a route for that ?
| class ReconciliationConfirmView(APIView): | ||
| """API endpoint to confirm user reconciliation emails. | ||
|
|
||
| GET /user_reconciliations/{user_type}/{confirmation_id}/ | ||
| Marks `active_email_checked` or `inactive_email_checked` to True. | ||
| """ |
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.
Could be nice to have a few tests about this part, to have like a blueprint on how to use it.
| class Meta: | ||
| verbose_name = _("user reconciliation") | ||
| verbose_name_plural = _("user reconciliations") |
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.
| class Meta: | |
| verbose_name = _("user reconciliation") | |
| verbose_name_plural = _("user reconciliations") | |
| class Meta: | |
| db_table = "impress_user_reconciliation" | |
| verbose_name = _("user reconciliation") | |
| verbose_name_plural = _("user reconciliations") |
By default the table will be created with core prefix otherwise.
| """To confirm that you are the one who initiated the request | ||
| and that this email belongs to you:""" | ||
| ), | ||
| "link": f"{domain}/user_reconciliations/{user_type}/{confirmation_id}/", |
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.
Nitpick, but could we change to hyphens ?
| "link": f"{domain}/user_reconciliations/{user_type}/{confirmation_id}/", | |
| "link": f"{domain}/user-reconciliations/{user_type}/{confirmation_id}/", |
052b0b3 to
d32ef62
Compare
|
After discussion with @AntoLC some data migration are missing. There are also relation with |
For now, the reconciliation requests are imported through CSV in the Django admin, which sends confirmation email to both addresses. When both are checked, the actual reconciliation is processed, in a threefold process (update document acess, update invitations, update user status.)
d32ef62 to
032413a
Compare
|
Size Change: +6.44 kB (+0.15%) Total Size: 4.2 MB
|
This changes the way the reconciliation requests CSV imports are processed and requires the CSV to provide a unique id for each request. Rows with errors are also now handled better so that they don't fail the whole import.
This changes the way the reconciliation requests CSV imports are processed and requires the CSV to provide a unique id for each request. Rows with errors are also now handled better so that they don't fail the whole import.
…ocs into sbl/user-reconciliation

Purpose
Fix #1616.
For now, the reconciliation requests are imported through CSV in the Django admin, which sends confirmation email to both addresses. When both are checked, the actual reconciliation is processed, in a threefold process (update document acess, update invitations, update user status.)
Proposal
UserReconciliationCsvImportmodel to manage the import of reconciliation requests through a task (user_reconciliation_csv_import_job)UserReconciliationmodel to store the user reconciliation requests themselves (a row = aactive_user/inactive_userpair)process_reconciliationadmin action process the action on the requested entries, if both emails have been checked.DocumentAccessitems, while managing the case where both users have access to the document (keeping the higher role)Invitationitems, while managing the case where both users have invitations for the document (keeping the higher role)is_activestatus on both usersDemo page reconciliation success
In waiting for @rl-83 to provide the design:
