OpenSlides/openslides/topics/views.py
Oskar Hahn 2daafa8db9 Created a function to convert anything possible to a user-collectoin-element or None
Changed user.has_perm(...) to has_perm(user, ...) at any place.

Removed old code
2017-01-26 18:57:10 +01:00

27 lines
807 B
Python

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.
"""
access_permissions = TopicAccessPermissions()
queryset = Topic.objects.all()
def check_view_permissions(self):
"""
Returns True if the user has required permissions.
"""
if self.action in ('list', 'retrieve'):
result = self.get_access_permissions().check_permissions(self.request.user)
else:
result = has_perm(self.request.user, 'agenda.can_manage')
return result