CMSgov / bluebutton-web-server

Blue Button API
https://sandbox.bluebutton.cms.gov
Other
40 stars 24 forks source link

BB2-3232: Filter inactive accounts #1208

Closed jimmyfagan closed 3 months ago

jimmyfagan commented 3 months ago

JIRA Ticket: BB2-3232

User Story or Bug Summary: I'd like to delete sandbox accounts which have had their activation keys expired. To facilitate this, I'm delivering code that will add some filters to the Users view in Django admin. We will now be able to filter by Active (users with Active status), Inactive (users with Inactive status), and Inactive (expired activation key) (users with inactive status and an expired activation key). By selecting the third option, it will be simple to delete all never-activated users as required by the ticket.

What Does This PR Do?

This PR adds a new filter to the Users admin view as described above.

What Should Reviewers Watch For?

If you have any knowledge of places we have unit tested this kind of code, let me know! I would love to add unit tests for this, but was unsure of where that would go or how it would work. Open to pairing as well.

You should test this by creating new accounts locally, to have a variety of cases in your User pool:

  1. An active account
  2. An account that once was active, but is no longer (should be fine to do this with Fred by deactivating him temporarily)
  3. An account that is inactive and whose key is expired (in reality this would be done by clicking on the activation link after the expires date, but you can just update the status of the activation key toexpired`)
  4. An account that is inactive, whose key status is created, and whose key expires is in the past
  5. An account that is inactive, whose key status is created, and whose key expires is in the future

It wasn't straightforward to adjust the expires value of the activation key to be in the past, so you can adjust the logic in the filter temporarily to test that case by changing datetime.today() to something like datetime.today()+timedelta(days=7).

We would expect that Active would give you account 1, Inactive would give you 2, 3, 4, 5, and Inactive (expired activation key) would give you 3, 4.

What Security Implications Does This PR Have?

None

What Needs to Be Merged and Deployed Before this PR?

None

Any Migrations?

Submitter Checklist

I have gone through and verified that...: