Fix email follow perms

This commit is contained in:
Stefan Wehrmeyer 2022-03-15 12:57:22 +01:00
parent 4215fe7319
commit 285e1a1f96
2 changed files with 8 additions and 7 deletions

View file

@ -39,6 +39,8 @@ class GovernmentAdmin(admin.ModelAdmin):
def has_limited_access(user): def has_limited_access(user):
if not user.is_authenticated:
return True
return not user.has_perm("froide_govplan.change_governmentplanupdate") return not user.has_perm("froide_govplan.change_governmentplanupdate")

View file

@ -6,8 +6,8 @@ from django.utils.translation import gettext_lazy as _
from froide.follow.configuration import FollowConfiguration from froide.follow.configuration import FollowConfiguration
from froide.helper.notifications import Notification, TemplatedEvent from froide.helper.notifications import Notification, TemplatedEvent
from .admin import get_allowed_plans from .admin import has_limited_access
from .models import GovernmentPlanFollower, GovernmentPlanUpdate from .models import GovernmentPlan, GovernmentPlanFollower, GovernmentPlanUpdate
class GovernmentPlanFollowConfiguration(FollowConfiguration): class GovernmentPlanFollowConfiguration(FollowConfiguration):
@ -30,13 +30,12 @@ class GovernmentPlanFollowConfiguration(FollowConfiguration):
} }
def get_content_object_queryset(self, request): def get_content_object_queryset(self, request):
return get_allowed_plans(request) if has_limited_access(request.user):
return GovernmentPlan.objects.filter(public=True)
return GovernmentPlan.objects.all()
def can_follow(self, content_object, user, request=None): def can_follow(self, content_object, user, request=None):
if request: return content_object.public or not has_limited_access(user)
get_allowed_plans(request)
return super().can_follow(content_object, user)
def get_batch_updates( def get_batch_updates(
self, start: datetime, end: datetime self, start: datetime, end: datetime