Fix email follow perms
This commit is contained in:
parent
4215fe7319
commit
285e1a1f96
2 changed files with 8 additions and 7 deletions
|
|
@ -39,6 +39,8 @@ class GovernmentAdmin(admin.ModelAdmin):
|
|||
|
||||
|
||||
def has_limited_access(user):
|
||||
if not user.is_authenticated:
|
||||
return True
|
||||
return not user.has_perm("froide_govplan.change_governmentplanupdate")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue