diff --git a/apps/activity/serializers.py b/apps/activity/serializers.py new file mode 100644 index 00000000..cca55751 --- /dev/null +++ b/apps/activity/serializers.py @@ -0,0 +1,38 @@ +# -*- mode: python; coding: utf-8 -*- +# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay +# SPDX-License-Identifier: GPL-3.0-or-later + +from .models import ActivityType, Activity, Guest +from rest_framework import serializers, viewsets + +class ActivityTypeSerializer(serializers.HyperlinkedModelSerializer): + class Meta: + model = ActivityType + fields = '__all__' + + +class ActivityTypeViewSet(viewsets.ModelViewSet): + queryset = ActivityType.objects.all() + serializer_class = ActivityTypeSerializer + + +class ActivitySerializer(serializers.HyperlinkedModelSerializer): + class Meta: + model = Activity + fields = '__all__' + + +class ActivityViewSet(viewsets.ModelViewSet): + queryset = Activity.objects.all() + serializer_class = ActivitySerializer + + +class GuestSerializer(serializers.HyperlinkedModelSerializer): + class Meta: + model = Guest + fields = '__all__' + + +class GuestViewSet(viewsets.ModelViewSet): + queryset = Guest.objects.all() + serializer_class = GuestSerializer diff --git a/apps/api/urls.py b/apps/api/urls.py index f18b7895..97e4ebe7 100644 --- a/apps/api/urls.py +++ b/apps/api/urls.py @@ -6,6 +6,7 @@ from django.conf.urls import url, include from django.contrib.auth.models import User from rest_framework import routers, serializers, viewsets from member.serializers import ProfileViewSet, ClubViewSet, RoleViewSet, MembershipViewSet +from activity.serializers import ActivityTypeViewSet, ActivityViewSet, GuestViewSet class UserSerializer(serializers.HyperlinkedModelSerializer): class Meta: @@ -19,10 +20,15 @@ class UserViewSet(viewsets.ModelViewSet): # Routers provide an easy way of automatically determining the URL conf. router = routers.DefaultRouter() router.register(r'users', UserViewSet) -router.register(r'profiles', ProfileViewSet) -router.register(r'clubs', ClubViewSet) -router.register(r'roles', RoleViewSet) -router.register(r'memberships', MembershipViewSet) + +router.register(r'members/profiles', ProfileViewSet) +router.register(r'members/clubs', ClubViewSet) +router.register(r'members/roles', RoleViewSet) +router.register(r'members/memberships', MembershipViewSet) + +router.register(r'activity/activity_types', ActivityTypeViewSet) +router.register(r'activity/activities', ActivityViewSet) +router.register(r'activity/guests', GuestViewSet) # Wire up our API using automatic URL routing. # Additionally, we include login URLs for the browsable API.