Skip to content

Commit

Permalink
[chores] Simplified where clause in get_template_default_values view
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Apr 8, 2021
1 parent 7fa17d6 commit 3d82c1e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions openwisp_controller/config/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,11 @@ def get_template_default_values(request):
)
else:
pk_list.append(pk)
where = Q(organization=None)
where = Q(pk__in=pk_list)
if not user.is_superuser:
where |= Q(organization__in=user.organizations_managed)
if user.is_superuser:
where = Q()
where &= Q(pk__in=pk_list)
where = where & (
Q(organization=None) | Q(organization__in=user.organizations_managed)
)
values = Template.objects.filter(where).values_list('default_values', flat=True)
default_values = {}
for item in values:
Expand Down

0 comments on commit 3d82c1e

Please sign in to comment.