Fix visibility of plans in sections
This commit is contained in:
parent
5e43d627d7
commit
1ae085c39c
2 changed files with 15 additions and 2 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from django.db.models import Q
|
||||
|
||||
from .models import GovernmentPlan
|
||||
|
||||
|
||||
|
|
@ -12,3 +14,14 @@ def get_allowed_plans(request):
|
|||
return GovernmentPlan.objects.all()
|
||||
groups = request.user.groups.all()
|
||||
return GovernmentPlan.objects.filter(group__in=groups).distinct()
|
||||
|
||||
|
||||
def get_visible_plans(request):
|
||||
if not has_limited_access(request.user):
|
||||
return GovernmentPlan.objects.all()
|
||||
if request.user.is_authenticated:
|
||||
groups = request.user.groups.all()
|
||||
return GovernmentPlan.objects.filter(
|
||||
Q(public=True) | Q(group__in=groups)
|
||||
).distinct()
|
||||
return GovernmentPlan.objects.filter(public=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue