Skip to content

Commit

Permalink
Add basic RoleView and serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
robines committed Sep 24, 2024
1 parent e4f64a7 commit ad62b87
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
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 @@ -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 #
# =============================== #
Expand Down

0 comments on commit ad62b87

Please sign in to comment.