2016-09-18 22:14:24 +02:00
|
|
|
from openslides.utils.rest_api import ModelViewSet
|
|
|
|
|
2019-03-06 14:53:24 +01:00
|
|
|
from ..utils.auth import has_perm
|
2016-09-18 22:14:24 +02:00
|
|
|
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
|
|
|
|
2016-09-18 22:14:24 +02:00
|
|
|
queryset = Topic.objects.all()
|
|
|
|
|
|
|
|
def check_view_permissions(self):
|
|
|
|
"""
|
|
|
|
Returns True if the user has required permissions.
|
|
|
|
"""
|
2021-03-04 16:15:57 +01:00
|
|
|
if self.action in ("create", "update", "partial_update", "destroy"):
|
2019-01-06 16:22:33 +01:00
|
|
|
result = has_perm(self.request.user, "agenda.can_manage")
|
2021-03-04 16:15:57 +01:00
|
|
|
else:
|
|
|
|
result = False
|
2016-09-18 22:14:24 +02:00
|
|
|
return result
|