cisagov / manage.get.gov

A Django-based domain name registrar used by the .gov domain to communicate with an EPP registry
https://get.gov
Other
53 stars 14 forks source link

Add UserPortfolioRoles table in Django admin #2366

Open abroddrick opened 4 days ago

abroddrick commented 4 days ago

Issue description

For the org model MVP, we have several features that we need to show/hide based on user permissions, such as domain management, managing requests, user management (at the whole portfolio level) and so on. That said, as we build out views for domain management in particular, we are going to need to have a permission system in place so that we can get started with these conditional views.

We also, are only showing portfolio based on the creator of the portfolio, but the goal will be to retrieve the portfolio that the user has permissions to, just like we currently get the domains they have management rights to.

The third thing permissions will be used for is showing a human readable permission next to user names such as "org member", "domain manager" "admin" and "read-only admin". This human readable name will eventually need to appear in the both django admin (for easy analyst viewing) and in a Portfolio User Management page to our users.

The scope of this ticket: Given the above needs, set up the foundation for permissions, such that at the completion of this ticket, a developer could

  1. easily associate the org_model flag to an org_member user group
  2. add a UserPortfolioRole to their user account
  3. have permissions change for their user account to match the role(s) assigned

Acceptance criteria

Additional context

For permissions, we could do a table for permissions or just use enums. If using enums I would associate each role with unique permissions that can build/layer on top of eachother.

For UserPortfolioRoles modifying user permissions, I would avoid using signals if possible and try to use the on save feature and overriding the built in delete function as needed.

*note for overriding delete, just do

 def delete(self, *args, **kwargs):
    #remove from the user group
    super().delete(*args, **kwargs)

Links to other issues

abroddrick commented 4 days ago

Assigned to myself to complete creation

abroddrick commented 12 hours ago

tentatively adding to next sprint