Skip to content

Commit

Permalink
Add viewset for permissions (#1526)
Browse files Browse the repository at this point in the history
  • Loading branch information
robines authored Oct 13, 2024
1 parent cb0ac78 commit d123221
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions backend/samfundet/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions backend/samfundet/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
8 changes: 7 additions & 1 deletion backend/samfundet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -65,6 +65,7 @@
TextItemSerializer,
InterviewSerializer,
EventGroupSerializer,
PermissionSerializer,
RecruitmentSerializer,
ClosedPeriodSerializer,
FoodCategorySerializer,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d123221

Please sign in to comment.