Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backend viewset for permissions #1526

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading