Skip to content

Commit

Permalink
Merge pull request #1308 from dandi/consistent-order-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandenburgh committed Oct 4, 2022
2 parents 9497091 + 376b87e commit 79b088e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions dandiapi/api/views/version.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from django.db import transaction
from django.utils.decorators import method_decorator
from django_filters import rest_framework as filters
from drf_yasg.utils import no_body, swagger_auto_schema
from guardian.decorators import permission_required_or_403
from rest_framework import filters, status
from rest_framework import status
from rest_framework.decorators import action
from rest_framework.exceptions import NotAuthenticated, PermissionDenied, ValidationError
from rest_framework.generics import get_object_or_404
Expand All @@ -21,15 +22,23 @@
)


class VersionFilter(filters.FilterSet):
order = filters.OrderingFilter(fields=['created'])

class Meta:
model = Version
fields = ['created']


class VersionViewSet(NestedViewSetMixin, DetailSerializerMixin, ReadOnlyModelViewSet):
queryset = Version.objects.all().select_related('dandiset').order_by('created')

serializer_class = VersionSerializer
serializer_detail_class = VersionDetailSerializer
pagination_class = DandiPagination

filter_backends = [filters.OrderingFilter]
ordering_fields = ['created']
filter_backends = [filters.DjangoFilterBackend]
filterset_class = VersionFilter

lookup_field = 'version'
lookup_value_regex = Version.VERSION_REGEX
Expand Down

0 comments on commit 79b088e

Please sign in to comment.