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

@ -6,8 +6,8 @@ from django.utils.translation import gettext_lazy as _
from froide.follow.configuration import FollowConfiguration
from froide.helper.notifications import Notification, TemplatedEvent
from .admin import get_allowed_plans
from .models import GovernmentPlanFollower, GovernmentPlanUpdate
from .admin import has_limited_access
from .models import GovernmentPlan, GovernmentPlanFollower, GovernmentPlanUpdate
class GovernmentPlanFollowConfiguration(FollowConfiguration):
@ -30,13 +30,12 @@ class GovernmentPlanFollowConfiguration(FollowConfiguration):
}
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):
if request:
get_allowed_plans(request)
return super().can_follow(content_object, user)
return content_object.public or not has_limited_access(user)
def get_batch_updates(
self, start: datetime, end: datetime