Skip to content

Commit

Permalink
Do not include revoked grantes when showing users list of managers.
Browse files Browse the repository at this point in the history
  • Loading branch information
amanning9 committed Jan 10, 2023
1 parent 781c6fb commit 5923df0
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions jasmin_services/views/service_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,6 @@ def service_details(request, service):
Displays details for a service, including details of current access and requests.
"""
# Get all the current managers and deputies of a services so that
# we can display this information to users of the service.
managers = (
Grant.objects.filter(
access__role__service=service,
expires__gt=date.today(),
)
.filter_active()
.filter(access__role__name="MANAGER")
)
managers = [x.access.user for x in managers]
deputies = (
Grant.objects.filter(
access__role__service=service,
expires__gt=date.today(),
)
.filter_active()
.filter(access__role__name="DEPUTY")
)
deputies = [x.access.user for x in deputies]

# Get the active grants and requests for the service as a whole
all_grants = Grant.objects.filter(
Expand Down Expand Up @@ -92,6 +72,33 @@ def service_details(request, service):
continue
roles.append(role)

if grants:
# Get all the current managers and deputies of a services so that
# we can display this information to users of the service.
managers = (
Grant.objects.filter(
access__role__service=service,
expires__gt=date.today(),
revoked=False,
)
.filter_active()
.filter(access__role__name="MANAGER")
)
managers = [x.access.user for x in managers]
deputies = (
Grant.objects.filter(
access__role__service=service,
expires__gt=date.today(),
revoked=False,
)
.filter_active()
.filter(access__role__name="DEPUTY")
)
deputies = [x.access.user for x in deputies]
else:
managers = []
deputies = []

templates = [
f"jasmin_services/{service.category.name}/{service.name}/service_details.html",
f"jasmin_services/{service.category.name}/service_details.html",
Expand Down

0 comments on commit 5923df0

Please sign in to comment.