Skip to content

Commit

Permalink
Change queryset value in group permission
Browse files Browse the repository at this point in the history
  • Loading branch information
susilnem committed Dec 17, 2024
1 parent 404a88c commit 9acc9c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
12 changes: 4 additions & 8 deletions local_units/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ def has_object_permission(self, request, view, object):
user = request.user

# Check if user is superuser or in Local Unit Global Validators group
group_queryset = (
Group.objects.filter(
name="Local Unit Global Validators",
user=user,
)
.values_list("id", flat=True)
.first()
)
group_queryset = Group.objects.filter(
name="Local Unit Global Validators",
user=user,
).first()

if user.is_superuser or group_queryset:
return True
Expand Down
12 changes: 4 additions & 8 deletions local_units/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,10 @@ def get_validate(self, request, pk=None, version=None):
# Checking the validator type

validator = LocalUnitChangeRequest.Validator.LOCAL
group_queryset = (
Group.objects.filter(
name="Local Unit Global Validators",
user=request.user,
)
.values_list("id", flat=True)
.first()
)
group_queryset = Group.objects.filter(
name="Local Unit Global Validators",
user=request.user,
).first()
if request.user.is_superuser or group_queryset:
validator = LocalUnitChangeRequest.Validator.GLOBAL
else:
Expand Down

0 comments on commit 9acc9c2

Please sign in to comment.