ordering fixed

This commit is contained in:
Qwann 2017-08-13 15:44:38 +02:00
parent a3197bf44f
commit 3ff4c2c2fe

View file

@ -4,6 +4,7 @@ from django.shortcuts import get_object_or_404
from django.utils.functional import cached_property from django.utils.functional import cached_property
from rest_framework.viewsets import ModelViewSet from rest_framework.viewsets import ModelViewSet
from rest_framework.filters import OrderingFilter
from event.models import Activity, ActivityTag, ActivityTemplate, Event, Place from event.models import Activity, ActivityTag, ActivityTemplate, Event, Place
@ -75,7 +76,10 @@ class EventViewSet(ModelViewSet):
queryset = Event.objects.all() queryset = Event.objects.all()
serializer_class = EventSerializer serializer_class = EventSerializer
ordering = 'beginning_date' filter_backends = (OrderingFilter,)
ordering_fields = ('title', 'creation_date', 'beginning_date',
'ending_date', )
ordering = ('beginning_date', )
def perform_create(self, serializer): def perform_create(self, serializer):
serializer.save(created_by=self.request.user) serializer.save(created_by=self.request.user)
@ -85,23 +89,33 @@ class PlaceViewSet(EventSpecificModelViewSet):
queryset = Place.objects.all() queryset = Place.objects.all()
serializer_class = PlaceSerializer serializer_class = PlaceSerializer
ordering = 'name' filter_backends = (OrderingFilter,)
ordering_fields = ('name', )
ordering = ('name', )
class ActivityTagViewSet(EventSpecificModelViewSet): class ActivityTagViewSet(EventSpecificModelViewSet):
queryset = ActivityTag.objects.all() queryset = ActivityTag.objects.all()
serializer_class = ActivityTagSerializer serializer_class = ActivityTagSerializer
ordering = ('is_public', 'name') filter_backends = (OrderingFilter,)
ordering_fields = ('is_public', 'name', )
ordering = ('is_public', 'name', )
class ActivityTemplateViewSet(EventModelViewSet): class ActivityTemplateViewSet(EventModelViewSet):
queryset = ActivityTemplate.objects.all() queryset = ActivityTemplate.objects.all()
serializer_class = ActivityTemplateSerializer serializer_class = ActivityTemplateSerializer
ordering = 'title' filter_backends = (OrderingFilter,)
ordering_fields = ('title', )
ordering = ('title', )
class ActivityViewSet(EventModelViewSet): class ActivityViewSet(EventModelViewSet):
queryset = Activity.objects.all() queryset = Activity.objects.all()
serializer_class = ActivitySerializer serializer_class = ActivitySerializer
filter_backends = (OrderingFilter,)
ordering_fields = ('title', )
ordering = ('title', )