Commit 690e7f29 authored by alexandre's avatar alexandre
Browse files

Sorting sorted out

parent 980536cb
......@@ -18,6 +18,22 @@ window.W = window.W || {};
parseRecords: function (resp, options) {
return resp.results;
},
queryParams: {
currentPage: "page",
pageSize: "page_size",
totalRecords: "count",
// See <https://github.com/backbone-paginator/backbone.paginator/issues/264>
order: null,
sortKey: "ordering",
ordering: function () {
var sortKey = this.state.sortKey, order = this.state.order;
if (sortKey && order !== 0) {
return (order === 1 ? '-' : '') + sortKey;
}
return null;
}
}
});
......
......@@ -1381,18 +1381,12 @@ window.W = window.W || {};
state: {
pageSize: 25,
firstPage: 1,
currentPage: 1
},
queryParams: {
currentPage: "page",
pageSize: "page_size",
totalRecords: "count"
},
currentPage: 1,
sortKey: "created_at",
order: -1
}
});
window.sc = scoreCollection;
var myListView = new W.ListView({
collection: scoreCollection
});
......
......@@ -2,6 +2,8 @@ from django.views.generic.base import TemplateView
from rest_framework import viewsets
from rest_framework.pagination import PageNumberPagination
from rest_framework.parsers import FormParser, MultiPartParser
from rest_framework.filters import OrderingFilter
# from django_filters.rest_framework import DjangoFilterBackend
from .models import Attachment, Score
from .serializers import AttachmentSerializer, ScoreSerializer
......@@ -29,7 +31,8 @@ class ScoreViewSet(viewsets.ModelViewSet):
queryset = Score.objects.all()
serializer_class = ScoreSerializer
pagination_class = ScoreViewSetPagination
filter_backends = (OrderingFilter,)
class ScoreView(TemplateView):
"""
......
Markdown is supported
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