OpenSlides/openslides/topics/views.py
Norman Jäckel cab53f0434 Moved custom slides to own app topics for better app structure.
Renamed model to Topic. Added migrations file. Fixed #2402.
2016-09-21 15:00:23 +02:00

26 lines
772 B
Python

from openslides.utils.rest_api import ModelViewSet
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 = self.request.user.has_perm('agenda.can_manage')
return result