-
-
Notifications
You must be signed in to change notification settings - Fork 219
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
Log changes to Web User Invitations #35744
base: master
Are you sure you want to change the base?
Conversation
…the invite when updating it
:param changed_by: user_id of the invitee or the invitation editor | ||
:param changed_via: INVITATION_CHANGED_VIA_* const (for now just web or api) | ||
:param action: CREATE, UPDATE or DELETE | ||
:param invite: the Invitation object itself. defaults to None for DELETE actions |
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.
Does that mean we drop the invite from the DB when deleting?
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.
yep deleted in web.py
corehq/apps/users/views/__init__.py
Outdated
@@ -1315,6 +1342,55 @@ def _get_sql_locations(self, primary_location_id, assigned_location_ids): | |||
if assigned_location_id is not None] | |||
return primary_location, assigned_locations | |||
|
|||
def _get_and_set_changes(self, invite, form_data, profile): | |||
change_values = [None] * 5 |
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.
🤞 nothings breaks in the future because somebody changes the order here but not in _format_changes
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.
good point! I can change this to a dict
corehq/apps/users/views/__init__.py
Outdated
invitation.custom_user_data = data.get("custom_user_data", {}) | ||
|
||
invitation.role = data.get("role") | ||
invitation.program = data.get("program", None) | ||
invitation.tableau_role = data.get("tableau_role", None) |
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 there a reason we don't care about tracking changes to the tableau settings?
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.
For user changes these aren't logged (maybe because they're logged directly in tableau?) but really, in my hastiness (and inability to test it locally) I totally forgot to include those. I'll add those as keys to the final changes dict, if there are any changes from the values stored in the Invitation
corehq/apps/users/views/web.py
Outdated
domain=domain, | ||
user_id=user.user_id if user else None, | ||
changed_by=request.couch_user.user_id, | ||
changed_via=INVITATION_CHANGE_VIA_WEB, |
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.
Are you sure this not also called via the API?
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.
or is there not delete API?
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.
None of the documentation/API change PRs I've looked at say we currently support deleting invites through the API but happy to be proven wrong!!
Sorry yall I'm doing a little more refactoring to contain the logging instances within the Invitation class's create/delete/save methods - might be a bit messy until then |
… created via bulk upload + log changes to tableau related fields + minor changes
Technical Summary
Jira Ticket
Brief tech spec
With the introduction of editable web user invites, we now have a need to additionally log changes made to these invites. This PR add logs for creating, editing and deleting invitations via the UI (in the Web User page) or through the Invitation creation API (currently there is no way to edit or delete invites using the API).
The new
InvitationHistory
logging class is a stripped down version of the currently existingUserHistory
logging class with 2 big differences: theuser_id
is an optional field because invites can be made for user that haven't registered yet and thechanges
field combines thechanges
andchange_message
field into one dict/field.Safety Assurance
Safety story
Tested locally and on staging to verify the logs contain the info I expect it to.
Automated test coverage
QA Plan
Migrations
Rollback instructions
Will have to roll back the migration first!
Labels & Review