From cd1ed08ca6862218665588602064ee5d91ed8ac0 Mon Sep 17 00:00:00 2001 From: Qwann Date: Sat, 22 Jul 2017 02:09:31 +0200 Subject: [PATCH] tag added to API --- api/event/serializers.py | 6 ++++-- api/event/views.py | 7 +------ api/urls.py | 1 + 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/api/event/serializers.py b/api/event/serializers.py index b7b9a08..741c01e 100644 --- a/api/event/serializers.py +++ b/api/event/serializers.py @@ -48,12 +48,14 @@ class PlaceSerializer(EventSpecificSerializer): fields = ('url', 'id', 'name', 'description', 'event') + # TODO rajouter des permissions -class ActivityTagSerializer(serializers.HyperlinkedModelSerializer): +class ActivityTagSerializer(EventSpecificSerializer): + event = EventSerializer(allow_null=True, read_only=True) class Meta: model = ActivityTag - fields = ('url', 'id', 'name', 'is_public', 'color',) + fields = ('url', 'id', 'name', 'is_public', 'color', 'event') # TODO rajouter des permissions diff --git a/api/event/views.py b/api/event/views.py index 81a85c9..b4a7ff4 100644 --- a/api/event/views.py +++ b/api/event/views.py @@ -56,12 +56,7 @@ class PlaceViewSet(EventSpecificViewSet): serializer_class = PlaceSerializer -class ActivityTagViewSet(ModelViewSet): - """ - This viewset automatically provides `list`, `create`, `retrieve`, - `update` and `destroy` actions. - - """ +class ActivityTagViewSet(EventSpecificViewSet): queryset = ActivityTag.objects.all() serializer_class = ActivityTagSerializer diff --git a/api/urls.py b/api/urls.py index 9c2b0a4..60ae603 100644 --- a/api/urls.py +++ b/api/urls.py @@ -13,6 +13,7 @@ router.register(r'activitytemplate', ActivityTemplateViewSet) # Register nested router and register someviewsets vith it event_router = NestedSimpleRouter(router, r'event', lookup='event') event_router.register(r'place', PlaceViewSet, base_name='event-names') +event_router.register(r'tag', ActivityTagViewSet, base_name='event-names') # The API URLs are now determined automatically by the router.