From ad62b87757b9d96223d35020a2030cc27d2ed43e Mon Sep 17 00:00:00 2001 From: robines Date: Tue, 24 Sep 2024 16:36:16 +0200 Subject: [PATCH] Add basic RoleView and serializer --- backend/samfundet/serializers.py | 7 +++++++ backend/samfundet/urls.py | 1 + backend/samfundet/views.py | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/backend/samfundet/serializers.py b/backend/samfundet/serializers.py index d2032f4ee..e959efa61 100644 --- a/backend/samfundet/serializers.py +++ b/backend/samfundet/serializers.py @@ -18,6 +18,7 @@ from root.constants import PHONE_NUMBER_REGEX from root.utils.mixins import CustomBaseSerializer +from .models.role import Role from .models.event import Event, EventGroup, EventCustomTicket, PurchaseFeedbackModel, PurchaseFeedbackQuestion, PurchaseFeedbackAlternative from .models.billig import BilligEvent, BilligPriceGroup, BilligTicketGroup from .models.general import ( @@ -484,6 +485,12 @@ class Meta: fields = '__all__' +class RoleSerializer(CustomBaseSerializer): + class Meta: + model = Role + fields = '__all__' + + class SaksdokumentSerializer(CustomBaseSerializer): # Read only url file path used in frontend url = serializers.SerializerMethodField(method_name='get_url', read_only=True) diff --git a/backend/samfundet/urls.py b/backend/samfundet/urls.py index cc49592f0..d4b433933 100644 --- a/backend/samfundet/urls.py +++ b/backend/samfundet/urls.py @@ -36,6 +36,7 @@ router.register('key-value', views.KeyValueView, 'key_value') router.register('organizations', views.OrganizationView, 'organizations') router.register('merch', views.MerchView, 'merch') +router.register('role', views.RoleView, 'role') ########## Recruitment ########## router.register('recruitment', views.RecruitmentView, 'recruitment') diff --git a/backend/samfundet/views.py b/backend/samfundet/views.py index d8f9122ae..f05c19f90 100644 --- a/backend/samfundet/views.py +++ b/backend/samfundet/views.py @@ -38,10 +38,12 @@ from .utils import event_query, generate_timeslots, get_occupied_timeslots_from_request from .homepage import homepage +from .models.role import Role from .serializers import ( TagSerializer, GangSerializer, MenuSerializer, + RoleSerializer, UserSerializer, EventSerializer, GroupSerializer, @@ -310,6 +312,12 @@ class BlogPostView(ModelViewSet): queryset = BlogPost.objects.all() +class RoleView(ModelViewSet): + permission_classes = (DjangoModelPermissionsOrAnonReadOnly,) + serializer_class = RoleSerializer + queryset = Role.objects.all() + + # =============================== # # Sulten # # =============================== #