Verified Commit 3b6f523d authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Add ordering instead of shortlist route

parent e60f6bfd
......@@ -179,7 +179,7 @@ class RegistrationSerializer(serializers.ModelSerializer):
def _queue_position(self, instance):
return (instance.queue_position()
if instance.queue_position() > 0 else None)
if instance.queue_position() > 0 else None)
def _is_cancelled(self, instance):
return instance.date_cancelled is not None
from datetime import datetime
from django.utils import timezone
from rest_framework import viewsets
from rest_framework import viewsets, filters
from rest_framework.decorators import list_route, detail_route
from rest_framework.exceptions import ParseError
from rest_framework.permissions import IsAuthenticated, IsAdminUser
......@@ -31,9 +31,11 @@ def _extract_date_range(request):
class EventViewset(viewsets.ReadOnlyModelViewSet):
queryset = Event.objects.filter(, published=True)
queryset = Event.objects.filter(,
permission_classes = [IsAuthenticated]
filter_backends = (filters.OrderingFilter,)
ordering_fields = ('start', 'end')
def get_serializer_class(self):
if self.action == 'list':
......@@ -67,21 +69,6 @@ class EventViewset(viewsets.ReadOnlyModelViewSet):
return Response(
def shortlist(self, request):
days = Event.objects.filter(, published=True
).datetimes('start', 'day')[:2]
data = list(map(lambda day: EventListSerializer(Event.objects.filter(,
), many=True, context={'request': request}).data, days))
return Response(data)
def calendarjs(self, request):
end, start = _extract_date_range(request)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment