Skip to content

Commit

Permalink
Merge pull request #466 from Terralego/improve-get-source-filtered
Browse files Browse the repository at this point in the history
Add model type and status to source filterset
  • Loading branch information
submarcos authored Feb 6, 2024
2 parents 2656fd1 + 44f7b5f commit b113e13
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/source/others/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Changelog
==========


2024.02.4+dev (XXXX-XX-XX)
---------------------------

**Improvements:**

- Sources in admin can now be sorted / filtered by model type and update date


2024.02.4 (2024-02-05)
---------------------------

Expand Down
9 changes: 8 additions & 1 deletion project/geosource/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@ class SourceFilterSet(filters.FilterSet):

class Meta:
model = Source
fields = ("polymorphic_ctype", "geom_type", "q", "status", "report__status")
fields = (
"polymorphic_ctype",
"polymorphic_ctype__model",
"report__status",
"geom_type",
"q",
"status",
)
2 changes: 2 additions & 0 deletions project/geosource/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,11 @@ class Meta:
"name",
"geom_type",
"report",
"updated_at",
"layers",
"updated_at",
)
extras = {"read_only": {"updated_at": True}}

def get__type(self, instance):
return instance.__class__.__name__
Expand Down
1 change: 1 addition & 0 deletions project/geosource/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class SourceModelViewset(ModelViewSet):
"geom_type",
"id",
"slug",
"updated_at",
)
filterset_class = SourceFilterSet
search_fields = ["name"]
Expand Down

0 comments on commit b113e13

Please sign in to comment.