From f2dd0362bb05598d19ce4617a704c3ba12a40127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Farcy=60?= Date: Fri, 15 Dec 2023 11:55:53 +0100 Subject: [PATCH] Allow sorting sources by updated date --- docs/source/others/changelog.rst | 3 ++- project/geosource/serializers.py | 2 ++ project/geosource/views.py | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/source/others/changelog.rst b/docs/source/others/changelog.rst index b8c58692..94aaa4df 100644 --- a/docs/source/others/changelog.rst +++ b/docs/source/others/changelog.rst @@ -7,7 +7,8 @@ Changelog **Improvements:** -- Api result for are now filterable by model type and status +- Api result for sources are now filterable by model type and status +- Api result for sources Sources are now sortable by updated date 2023.11.2 (2023-11-22) diff --git a/project/geosource/serializers.py b/project/geosource/serializers.py index c9b2c060..6502be73 100644 --- a/project/geosource/serializers.py +++ b/project/geosource/serializers.py @@ -172,7 +172,9 @@ class Meta: "name", "geom_type", "report", + "updated_at", ) + extras = {"read_only": {"updated_at": True}} def get__type(self, instance): return instance.__class__.__name__ diff --git a/project/geosource/views.py b/project/geosource/views.py index 6662b3b3..207bb07e 100644 --- a/project/geosource/views.py +++ b/project/geosource/views.py @@ -20,6 +20,7 @@ class SourceModelViewset(ModelViewSet): "geom_type", "id", "slug", + "updated_at", ) filterset_class = SourceFilterSet search_fields = ["name"]