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 basic CRUD backend for Roles #1393

Merged
merged 3 commits into from
Sep 24, 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
7 changes: 7 additions & 0 deletions backend/samfundet/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions backend/samfundet/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
8 changes: 8 additions & 0 deletions backend/samfundet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -312,6 +314,12 @@ class BlogPostView(ModelViewSet):
queryset = BlogPost.objects.all()


class RoleView(ModelViewSet):
permission_classes = (DjangoModelPermissionsOrAnonReadOnly,)
robines marked this conversation as resolved.
Show resolved Hide resolved
serializer_class = RoleSerializer
queryset = Role.objects.all()


# =============================== #
# Sulten #
# =============================== #
Expand Down
Loading