Fix visibility of non-public plans in section list
This commit is contained in:
parent
07d562f2d8
commit
5e43d627d7
4 changed files with 25 additions and 21 deletions
14
froide_govplan/auth.py
Normal file
14
froide_govplan/auth.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from .models import GovernmentPlan
|
||||
|
||||
|
||||
def has_limited_access(user):
|
||||
if not user.is_authenticated:
|
||||
return True
|
||||
return not user.has_perm("froide_govplan.add_governmentplan")
|
||||
|
||||
|
||||
def get_allowed_plans(request):
|
||||
if not has_limited_access(request.user):
|
||||
return GovernmentPlan.objects.all()
|
||||
groups = request.user.groups.all()
|
||||
return GovernmentPlan.objects.filter(group__in=groups).distinct()
|
||||
Loading…
Add table
Add a link
Reference in a new issue