Skip to content
Snippets Groups Projects
Forked from KIF / AKPlanning
318 commits behind the upstream repository.
  • Benjamin Hättasch's avatar
    028be1ee
    Split AKModel views into different files & introduce modular status page · 028be1ee
    Benjamin Hättasch authored
    Move AKModel views into several subfiles to improve overview and resolve problems with circular imports
    Introduce new modular status page handling (widgets and views)
    Port main status page to new structure
    Move AK messages status page visualization to AKSubmission (therefore, they automatically do not show up when there is no possibility to create them)
    Introduce status widget for virtual rooms
    Fix timezone issue for rendering of AK messages on status page
    Adapt status page URL in several views and tests
    028be1ee
    History
    Split AKModel views into different files & introduce modular status page
    Benjamin Hättasch authored
    Move AKModel views into several subfiles to improve overview and resolve problems with circular imports
    Introduce new modular status page handling (widgets and views)
    Port main status page to new structure
    Move AK messages status page visualization to AKSubmission (therefore, they automatically do not show up when there is no possibility to create them)
    Introduce status widget for virtual rooms
    Fix timezone issue for rendering of AK messages on status page
    Adapt status page URL in several views and tests
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
api.py 2.37 KiB
from rest_framework import mixins, viewsets, permissions

from AKModel.metaviews.admin import EventSlugMixin
from AKModel.models import AKOwner, AKCategory, AKTrack, AK, Room, AKSlot
from AKModel.serializers import AKOwnerSerializer, AKCategorySerializer, AKTrackSerializer, AKSerializer, \
    RoomSerializer, AKSlotSerializer


class AKOwnerViewSet(EventSlugMixin, mixins.RetrieveModelMixin, mixins.ListModelMixin, viewsets.GenericViewSet):
    permission_classes = (permissions.DjangoModelPermissionsOrAnonReadOnly,)
    serializer_class = AKOwnerSerializer

    def get_queryset(self):
        return AKOwner.objects.filter(event=self.event)


class AKCategoryViewSet(EventSlugMixin, mixins.RetrieveModelMixin, mixins.ListModelMixin, viewsets.GenericViewSet):
    permission_classes = (permissions.DjangoModelPermissionsOrAnonReadOnly,)
    serializer_class = AKCategorySerializer

    def get_queryset(self):
        return AKCategory.objects.filter(event=self.event)


class AKTrackViewSet(EventSlugMixin, mixins.RetrieveModelMixin, mixins.CreateModelMixin, mixins.UpdateModelMixin,
                     mixins.DestroyModelMixin, mixins.ListModelMixin, viewsets.GenericViewSet):
    permission_classes = (permissions.DjangoModelPermissionsOrAnonReadOnly,)
    serializer_class = AKTrackSerializer

    def get_queryset(self):
        return AKTrack.objects.filter(event=self.event)


class AKViewSet(EventSlugMixin, mixins.RetrieveModelMixin, mixins.UpdateModelMixin, mixins.ListModelMixin,
                viewsets.GenericViewSet):
    permission_classes = (permissions.DjangoModelPermissionsOrAnonReadOnly,)
    serializer_class = AKSerializer

    def get_queryset(self):
        return AK.objects.filter(event=self.event)


class RoomViewSet(EventSlugMixin, mixins.RetrieveModelMixin, mixins.ListModelMixin, viewsets.GenericViewSet):
    permission_classes = (permissions.DjangoModelPermissionsOrAnonReadOnly,)
    serializer_class = RoomSerializer

    def get_queryset(self):
        return Room.objects.filter(event=self.event)


class AKSlotViewSet(EventSlugMixin, mixins.RetrieveModelMixin, mixins.CreateModelMixin, mixins.UpdateModelMixin,
                    mixins.ListModelMixin, viewsets.GenericViewSet):
    permission_classes = (permissions.DjangoModelPermissionsOrAnonReadOnly,)
    serializer_class = AKSlotSerializer

    def get_queryset(self):
        return AKSlot.objects.filter(event=self.event)