tag added to API

This commit is contained in:
Qwann 2017-07-22 02:09:31 +02:00
parent 36f038259b
commit cd1ed08ca6
3 changed files with 6 additions and 8 deletions

View file

@ -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

View file

@ -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

View file

@ -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.