OpenSlides/server/openslides/topics/views.py

28 lines
808 B
Python
Raw Normal View History

from openslides.utils.rest_api import ModelViewSet
from ..utils.auth import has_perm
from .access_permissions import TopicAccessPermissions
from .models import Topic
class TopicViewSet(ModelViewSet):
"""
API endpoint for topics.
There are the following views: metadata, list, retrieve, create,
partial_update, update and destroy.
"""
2019-01-06 16:22:33 +01:00
access_permissions = TopicAccessPermissions()
queryset = Topic.objects.all()
def check_view_permissions(self):
"""
Returns True if the user has required permissions.
"""
2019-01-06 16:22:33 +01:00
if self.action in ("list", "retrieve"):
result = self.get_access_permissions().check_permissions(self.request.user)
else:
2019-01-06 16:22:33 +01:00
result = has_perm(self.request.user, "agenda.can_manage")
return result