Added api viewset for custom slides.
This commit is contained in:
parent
7ed5d2fc43
commit
7644cb9a09
@ -13,7 +13,9 @@ class CoreAppConfig(AppConfig):
|
|||||||
# Import all required stuff.
|
# Import all required stuff.
|
||||||
from openslides.config.signals import config_signal
|
from openslides.config.signals import config_signal
|
||||||
from openslides.projector.api import register_slide_model
|
from openslides.projector.api import register_slide_model
|
||||||
|
from openslides.utils.rest_api import router
|
||||||
from .signals import setup_general_config
|
from .signals import setup_general_config
|
||||||
|
from .views import CustomSlideViewSet
|
||||||
|
|
||||||
# Connect signals.
|
# Connect signals.
|
||||||
config_signal.connect(setup_general_config, dispatch_uid='setup_general_config')
|
config_signal.connect(setup_general_config, dispatch_uid='setup_general_config')
|
||||||
@ -21,3 +23,6 @@ class CoreAppConfig(AppConfig):
|
|||||||
# Register slides.
|
# Register slides.
|
||||||
CustomSlide = self.get_model('CustomSlide')
|
CustomSlide = self.get_model('CustomSlide')
|
||||||
register_slide_model(CustomSlide, 'core/customslide_slide.html')
|
register_slide_model(CustomSlide, 'core/customslide_slide.html')
|
||||||
|
|
||||||
|
# Register viewset.
|
||||||
|
router.register('core/customslide', CustomSlideViewSet)
|
||||||
|
11
openslides/core/serializers.py
Normal file
11
openslides/core/serializers.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from .models import CustomSlide
|
||||||
|
|
||||||
|
|
||||||
|
class CustomSlideSerializer(serializers.ModelSerializer):
|
||||||
|
"""
|
||||||
|
Serializer for a core.models.CustomSlide objects.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = CustomSlide
|
@ -12,14 +12,16 @@ from haystack.views import SearchView as _SearchView
|
|||||||
from openslides import get_version as get_openslides_version
|
from openslides import get_version as get_openslides_version
|
||||||
from openslides import get_git_commit_id, RELEASE
|
from openslides import get_git_commit_id, RELEASE
|
||||||
from openslides.config.api import config
|
from openslides.config.api import config
|
||||||
|
from openslides.utils import rest_api
|
||||||
|
from openslides.utils import views as utils_views
|
||||||
from openslides.utils.plugins import get_plugin_description, get_plugin_verbose_name, get_plugin_version
|
from openslides.utils.plugins import get_plugin_description, get_plugin_verbose_name, get_plugin_version
|
||||||
from openslides.utils.signals import template_manipulation
|
from openslides.utils.signals import template_manipulation
|
||||||
from openslides.utils import views as utils_views
|
|
||||||
from openslides.utils.widgets import Widget
|
from openslides.utils.widgets import Widget
|
||||||
|
|
||||||
from .forms import SelectWidgetsForm
|
from .forms import SelectWidgetsForm
|
||||||
from .models import CustomSlide, Tag
|
from .models import CustomSlide, Tag
|
||||||
from .exceptions import TagException
|
from .exceptions import TagException
|
||||||
|
from .serializers import CustomSlideSerializer
|
||||||
|
|
||||||
|
|
||||||
class DashboardView(utils_views.AjaxMixin, utils_views.TemplateView):
|
class DashboardView(utils_views.AjaxMixin, utils_views.TemplateView):
|
||||||
@ -291,3 +293,20 @@ class TagListView(utils_views.AjaxMixin, utils_views.ListView):
|
|||||||
action=getattr(self, 'action', None),
|
action=getattr(self, 'action', None),
|
||||||
error=getattr(self, 'error', None),
|
error=getattr(self, 'error', None),
|
||||||
**context)
|
**context)
|
||||||
|
|
||||||
|
|
||||||
|
class CustomSlideViewSet(rest_api.viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
API endpoint to view, edit and delete custom slides.
|
||||||
|
"""
|
||||||
|
model = CustomSlide
|
||||||
|
queryset = CustomSlide.objects.all()
|
||||||
|
serializer_class = CustomSlideSerializer
|
||||||
|
|
||||||
|
def check_permissions(self, request):
|
||||||
|
"""
|
||||||
|
Calls self.permission_denied() if the requesting user has not the
|
||||||
|
permission to manage.
|
||||||
|
"""
|
||||||
|
if not request.user.has_perm('core.can_manage_projector'):
|
||||||
|
self.permission_denied(request)
|
||||||
|
Loading…
Reference in New Issue
Block a user