Skip to content
Snippets Groups Projects
Select Git revision
  • 3c3b1070dc2699f4272a945d1093d3a3415a5905
  • main default protected
  • renovate/django-5.x
  • koma/feature/preference-polling-form
4 results

api.py

Blame
  • Benjamin Hättasch's avatar
    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
    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)