mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-16 01:27:03 +02:00
cleanup some code
This commit is contained in:
parent
08514a75dc
commit
09303401ed
3 changed files with 12 additions and 8 deletions
|
@ -7,6 +7,8 @@ Permissions on these roles are set through groups:
|
||||||
groups and the methods to create them are defined in
|
groups and the methods to create them are defined in
|
||||||
our `user_group` model and run in a migration.
|
our `user_group` model and run in a migration.
|
||||||
|
|
||||||
|
For more details, refer to the [user group model](../../src/registrar/models/user_group.py).
|
||||||
|
|
||||||
## Editing group permissions through code
|
## Editing group permissions through code
|
||||||
|
|
||||||
We can edit and deploy new group permissions by:
|
We can edit and deploy new group permissions by:
|
||||||
|
|
|
@ -192,6 +192,14 @@ class MyUserAdmin(BaseUserAdmin):
|
||||||
),
|
),
|
||||||
("Important dates", {"fields": ("last_login", "date_joined")}),
|
("Important dates", {"fields": ("last_login", "date_joined")}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
analyst_list_display = [
|
||||||
|
"email",
|
||||||
|
"first_name",
|
||||||
|
"last_name",
|
||||||
|
"group",
|
||||||
|
"status",
|
||||||
|
]
|
||||||
|
|
||||||
# NOT all fields are readonly for admin, otherwise we would have
|
# NOT all fields are readonly for admin, otherwise we would have
|
||||||
# set this at the permissions level. The exception is 'status'
|
# set this at the permissions level. The exception is 'status'
|
||||||
|
@ -219,13 +227,7 @@ class MyUserAdmin(BaseUserAdmin):
|
||||||
return super().get_list_display(request)
|
return super().get_list_display(request)
|
||||||
|
|
||||||
# Customize the list display for analysts
|
# Customize the list display for analysts
|
||||||
return (
|
return self.analyst_list_display
|
||||||
"email",
|
|
||||||
"first_name",
|
|
||||||
"last_name",
|
|
||||||
"group",
|
|
||||||
"status",
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_fieldsets(self, request, obj=None):
|
def get_fieldsets(self, request, obj=None):
|
||||||
if request.user.has_perm("registrar.full_access_permission"):
|
if request.user.has_perm("registrar.full_access_permission"):
|
||||||
|
|
|
@ -31,7 +31,7 @@ class TestGroups(TestCase):
|
||||||
UserGroup.objects.filter(name="full_access_group"), [full_access_group]
|
UserGroup.objects.filter(name="full_access_group"), [full_access_group]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Test permissions for cisa_analysts)group
|
# Test permissions for cisa_analysts_group
|
||||||
# Define the expected permission codenames
|
# Define the expected permission codenames
|
||||||
expected_permissions = [
|
expected_permissions = [
|
||||||
"view_logentry",
|
"view_logentry",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue