api: ensure viewsets have default ordering

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-10-05 11:26:41 +02:00
parent d0c56325ef
commit 782764ac73
3 changed files with 3 additions and 0 deletions

View file

@ -212,6 +212,7 @@ class UserViewSet(UsedByMixin, ModelViewSet):
"""User Viewset""" """User Viewset"""
queryset = User.objects.none() queryset = User.objects.none()
ordering = ["username"]
serializer_class = UserSerializer serializer_class = UserSerializer
search_fields = ["username", "name", "is_active", "email"] search_fields = ["username", "name", "is_active", "email"]
filterset_class = UsersFilter filterset_class = UsersFilter

View file

@ -108,6 +108,7 @@ class FlowViewSet(UsedByMixin, ModelViewSet):
queryset = Flow.objects.all() queryset = Flow.objects.all()
serializer_class = FlowSerializer serializer_class = FlowSerializer
lookup_field = "slug" lookup_field = "slug"
ordering = ["slug", "name"]
search_fields = ["name", "slug", "designation", "title"] search_fields = ["name", "slug", "designation", "title"]
filterset_fields = ["flow_uuid", "name", "slug", "designation"] filterset_fields = ["flow_uuid", "name", "slug", "designation"]

View file

@ -87,6 +87,7 @@ class PolicyViewSet(
"promptstage": ["isnull"], "promptstage": ["isnull"],
} }
search_fields = ["name"] search_fields = ["name"]
ordering = ["name"]
def get_queryset(self): # pragma: no cover def get_queryset(self): # pragma: no cover
return Policy.objects.select_subclasses().prefetch_related("bindings", "promptstage_set") return Policy.objects.select_subclasses().prefetch_related("bindings", "promptstage_set")