ordering fixed
This commit is contained in:
parent
a3197bf44f
commit
3ff4c2c2fe
1 changed files with 18 additions and 4 deletions
|
@ -4,6 +4,7 @@ from django.shortcuts import get_object_or_404
|
|||
from django.utils.functional import cached_property
|
||||
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
from rest_framework.filters import OrderingFilter
|
||||
|
||||
from event.models import Activity, ActivityTag, ActivityTemplate, Event, Place
|
||||
|
||||
|
@ -75,7 +76,10 @@ class EventViewSet(ModelViewSet):
|
|||
queryset = Event.objects.all()
|
||||
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):
|
||||
serializer.save(created_by=self.request.user)
|
||||
|
@ -85,23 +89,33 @@ class PlaceViewSet(EventSpecificModelViewSet):
|
|||
queryset = Place.objects.all()
|
||||
serializer_class = PlaceSerializer
|
||||
|
||||
ordering = 'name'
|
||||
filter_backends = (OrderingFilter,)
|
||||
ordering_fields = ('name', )
|
||||
ordering = ('name', )
|
||||
|
||||
|
||||
class ActivityTagViewSet(EventSpecificModelViewSet):
|
||||
queryset = ActivityTag.objects.all()
|
||||
serializer_class = ActivityTagSerializer
|
||||
|
||||
ordering = ('is_public', 'name')
|
||||
filter_backends = (OrderingFilter,)
|
||||
ordering_fields = ('is_public', 'name', )
|
||||
ordering = ('is_public', 'name', )
|
||||
|
||||
|
||||
class ActivityTemplateViewSet(EventModelViewSet):
|
||||
queryset = ActivityTemplate.objects.all()
|
||||
serializer_class = ActivityTemplateSerializer
|
||||
|
||||
ordering = 'title'
|
||||
filter_backends = (OrderingFilter,)
|
||||
ordering_fields = ('title', )
|
||||
ordering = ('title', )
|
||||
|
||||
|
||||
class ActivityViewSet(EventModelViewSet):
|
||||
queryset = Activity.objects.all()
|
||||
serializer_class = ActivitySerializer
|
||||
|
||||
filter_backends = (OrderingFilter,)
|
||||
ordering_fields = ('title', )
|
||||
ordering = ('title', )
|
||||
|
|
Loading…
Reference in a new issue