Skip to content

Commit

Permalink
revert back tests from is_staff to has_perm
Browse files Browse the repository at this point in the history
  • Loading branch information
rachidatecs committed Sep 30, 2023
1 parent 0c05518 commit 3580e07
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
11 changes: 5 additions & 6 deletions src/registrar/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,12 +842,11 @@ def has_change_permission(self, request, obj=None):
# Fixes a bug wherein users which are only is_staff
# can access 'change' when GET,
# but cannot access this page when it is a request of type POST.
# if request.user.has_perm(
# "registrar.full_access_permission"
# ) or request.user.has_perm(
# "registrar.analyst_access_permission"
# ):
if request.user.is_staff:
if request.user.has_perm(
"registrar.full_access_permission"
) or request.user.has_perm(
"registrar.analyst_access_permission"
):
return True
return super().has_change_permission(request, obj)

Expand Down
8 changes: 3 additions & 5 deletions src/registrar/views/utility/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ def can_access_other_user_domains(self, pk):
"""

# Check if the user is permissioned...
# user_is_analyst_or_superuser = self.request.user.has_perm(
# "registrar.analyst_access_permission"
# ) or self.request.user.has_perm("registrar.full_access_permission")

user_is_analyst_or_superuser = self.request.user.is_staff
user_is_analyst_or_superuser = self.request.user.has_perm(
"registrar.analyst_access_permission"
) or self.request.user.has_perm("registrar.full_access_permission")

if not user_is_analyst_or_superuser:
return False
Expand Down
7 changes: 3 additions & 4 deletions src/registrar/views/utility/permission_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ class DomainPermissionView(DomainPermission, DetailView, abc.ABC):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
user = self.request.user
# context["is_analyst_or_superuser"] = user.has_perm(
# "registrar.analyst_access_permission"
# ) or user.has_perm("registrar.full_access_permission")
context["is_analyst_or_superuser"] = user.is_staff
context["is_analyst_or_superuser"] = user.has_perm(
"registrar.analyst_access_permission"
) or user.has_perm("registrar.full_access_permission")
# Stored in a variable for the linter
action = "analyst_action"
action_location = "analyst_action_location"
Expand Down

0 comments on commit 3580e07

Please sign in to comment.