From d1232216a086d963db9955a49fec98ded0a84031 Mon Sep 17 00:00:00 2001 From: Robin <16273164+robines@users.noreply.github.com> Date: Sun, 13 Oct 2024 16:13:40 +0200 Subject: [PATCH] Add viewset for permissions (#1526) --- backend/samfundet/serializers.py | 6 ++++++ backend/samfundet/urls.py | 1 + backend/samfundet/views.py | 8 +++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/backend/samfundet/serializers.py b/backend/samfundet/serializers.py index ed80d9c54..0c3502112 100644 --- a/backend/samfundet/serializers.py +++ b/backend/samfundet/serializers.py @@ -345,6 +345,12 @@ class Meta: fields = '__all__' +class PermissionSerializer(serializers.ModelSerializer): + class Meta: + model = Permission + fields = '__all__' + + class ProfileSerializer(serializers.ModelSerializer): class Meta: model = Profile diff --git a/backend/samfundet/urls.py b/backend/samfundet/urls.py index afc42d0cc..a0246ae45 100644 --- a/backend/samfundet/urls.py +++ b/backend/samfundet/urls.py @@ -24,6 +24,7 @@ router.register('user-preference', views.UserPreferenceView, 'user_preference') router.register('saksdokument', views.SaksdokumentView, 'saksdokument') router.register('profile', views.ProfileView, 'profile') +router.register('permissions', views.PermissionView, 'permissions') router.register('menu', views.MenuView, 'menu') router.register('menu-items', views.MenuItemView, 'menu_items') router.register('food-preference', views.FoodPreferenceView, 'food_preference') diff --git a/backend/samfundet/views.py b/backend/samfundet/views.py index 86b043f88..f53726a25 100644 --- a/backend/samfundet/views.py +++ b/backend/samfundet/views.py @@ -28,7 +28,7 @@ from django.utils.encoding import force_bytes from django.middleware.csrf import get_token from django.utils.decorators import method_decorator -from django.contrib.auth.models import Group +from django.contrib.auth.models import Group, Permission from django.views.decorators.csrf import csrf_protect, ensure_csrf_cookie from root.constants import ( @@ -65,6 +65,7 @@ TextItemSerializer, InterviewSerializer, EventGroupSerializer, + PermissionSerializer, RecruitmentSerializer, ClosedPeriodSerializer, FoodCategorySerializer, @@ -507,6 +508,11 @@ class ProfileView(ModelViewSet): queryset = Profile.objects.all() +class PermissionView(ModelViewSet): + serializer_class = PermissionSerializer + queryset = Permission.objects.all() + + class WebhookView(APIView): """ https://docs.github.com/en/webhooks/using-webhooks/validating-webhook-deliveries