Fix visibility of non-public plans in section list

This commit is contained in:
Stefan Wehrmeyer 2022-06-20 11:18:38 +02:00
parent 07d562f2d8
commit 5e43d627d7
4 changed files with 25 additions and 21 deletions

View file

@ -13,6 +13,7 @@ from froide.helper.widgets import TagAutocompleteWidget
from froide.organization.models import Organization
from .api_views import GovernmentPlanViewSet
from .auth import get_allowed_plans, has_limited_access
from .forms import (
GovernmentPlanForm,
GovernmentPlanUpdateAcceptProposalForm,
@ -53,19 +54,6 @@ class GovernmentAdmin(admin.ModelAdmin):
list_filter = ("public",)
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()
def execute_assign_organization(admin, request, queryset, action_obj):
queryset.update(organization=action_obj)