-
Notifications
You must be signed in to change notification settings - Fork 19
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
Issue #2579 #2644: Analyst can merge user accounts - [BOB] #2649
Conversation
🥳 Successfully deployed to developer sandbox bob. |
console.error("Could not assign current user: no values found.") | ||
return; | ||
} | ||
if (document.getElementById("id_investigator") && django && django.jQuery) { |
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.
Relax, this is just an additional check for document.getElementById("id_investigator") && django && django.jQuery) to get rid of a console error. Nothing else in this file.
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
@rachidatecs Looks good, just two small updates:
Are you sure you want to transfer data and delete this user? This action cannot be undone. [Yes, transfer and delete user] [Cancel] |
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
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.
Works perfectly well for me. I have a concern with adding a hole in our csp for select2, but I don't think it's an unacceptable risk. Let me know if there's no acceptably convenient way around using it.
CSP_STYLE_SRC = [ | ||
"'self'", | ||
"https://www.ssa.gov/accessibility/andi/andi.css", | ||
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css", |
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 assume there was no other easy way to do this? Adding another hole in our CSP is not something we should do lightly. If somehow that version alias of select2 were to get replaced with something malicious anybody who accesses a view that loads scripts from this source could be vulnerable.
If it's going to be super expensive to replace this then it may be worth it, but I want to make sure it's something we're considering carefully.
<script src="{% static 'admin/js/vendor/jquery/jquery.min.js' %}"></script> | ||
|
||
<!-- Include Select2 JavaScript. Since this view technically falls outside of admin, this is needed. --> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js"></script> |
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.
This is what I was referencing earlier. If hypothetically the developers of select2 got hacked (or were deliberately malicious) they could upload arbitrary code at this url and it would execute in the users browser. This is a risk we take with basically all our dependencies, so it's not unacceptable, but again want to make sure it's carefully considered.
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.
select2 makes the django admin combobox possible on the transfer page. It's django source code basically. Without it, the transfer page would have to be registered as a django admin view (which it is not), or we'd need to use USWDS's combobox in this view's context. There might be a way to load this piece of Django's source code from our existing build but I couldn't figure it out.
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.
One option: We download the select2 script and load it from our static folder. Is it worth it though?
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.
^ Legit question, you or Alysia would be the ones best qualified to answer.
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'm cool with this as-is. Just wanted to make sure there wasn't an easy workaround.
</h2> | ||
<div class="usa-prose"> | ||
{% if selected_user != logged_in_user %} | ||
<p>Username: <b>{{ selected_user.username }}</b><br> |
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 an instance where the selected_user would be equal to the logged_in_user? Could we make a better 'else' message if so?
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.
This will be refactored in a future ticket that disallows this feature for any staff (analyst, superuser) user
def test_transfer_user_modal(self): | ||
"""Assert modal on page""" | ||
user_transfer_page = self.app.get(reverse("transfer_user", args=[self.user1.pk])) | ||
self.assertContains(user_transfer_page, "This action cannot be undone.") |
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 really like the use of tests here for different scenarios!
current_user.save() | ||
|
||
@classmethod | ||
def log_change(cls, obj, field_name, field_value, new_value, change_logs): |
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.
This is a really clean way of logging 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.
All good
🥳 Successfully deployed to developer sandbox bob. |
🥳 Successfully deployed to developer sandbox bob. |
Ticket
Resolves #2579
Resolves #2644
Changes
Transfer of user properties (portfolio and roles/perms)Context for reviewers
This turned to be a bit large, so we shed a couple of items to other tickets:
Refactor the join lookup on user transfer to work with the refactored portfolio (multiple per user instead of one) #2644 will refactor the portfolio transfer now that a user can have more than one portfolioSetup
Designers
As of Friday night the sandbox build is not running. Check for green checkmarks before you go to bob.
Code Review Verification Steps
As the original developer, I have
Satisfied acceptance criteria and met development standards
Ensured code standards are met (Original Developer)
Validated user-facing changes (if applicable)
As a code reviewer, I have
Reviewed, tested, and left feedback about the changes
Ensured code standards are met (Code reviewer)
Validated user-facing changes as a developer
New pages have been added to .pa11yci file so that they will be tested with our automated accessibility testing
Checked keyboard navigability
Meets all designs and user flows provided by design/product
Tested general usability, landmarks, page header structure, and links with a screen reader (such as Voiceover or ANDI)
Tested with multiple browsers, the suggestion is to use ones that the developer didn't (check off which ones were used)
(Rarely needed) Tested as both an analyst and applicant user
Note: Multiple code reviewers can share the checklists above, a second reviewers should not make a duplicate checklist
As a designer reviewer, I have
Verified that the changes match the design intention
Validated user-facing changes as a designer
Checked keyboard navigability
Tested general usability, landmarks, page header structure, and links with a screen reader (such as Voiceover or ANDI)
Tested with multiple browsers (check off which ones were used)
(Rarely needed) Tested as both an analyst and applicant user
Screenshots