Skip to content

Commit

Permalink
feat: add annex uri in API for Station objects. Allow user to display…
Browse files Browse the repository at this point in the history
… station name in admin for customcontributions
  • Loading branch information
babastienne committed May 7, 2024
1 parent ab0b8f2 commit 5bd2833
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion georiviere/contribution/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,15 @@ class CustomContribAttachmentInline(GenericTabularInline):

@admin.register(models.CustomContribution)
class CustomContributionAdmin(LeafletGeoAdmin, admin.ModelAdmin):
list_display = ("custom_type", "portal", "validated", "contributed_at", "date_insert", "date_update")
list_display = ("custom_type", "station", "portal", "validated", "contributed_at", "date_insert", "date_update")
list_filter = ("custom_type", "portal", "validated")
form = forms.CustomContributionForm
inlines = [CustomContribAttachmentInline]

def station(self, obj):
return obj.station.label
station.admin_order_field = 'label'

def get_readonly_fields(self, request, obj=None):
if not obj or not obj.pk:
return ("data",)
Expand Down
2 changes: 2 additions & 0 deletions georiviere/portal/serializers/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


class StationMixin(SerializerAPIMixin, ModelSerializer):
url = serializers.CharField(source="annex_uri")
json_url = serializers.SerializerMethodField()
geojson_url = serializers.SerializerMethodField()
geometry = geo_serializers.GeometryField(
Expand Down Expand Up @@ -35,6 +36,7 @@ class Meta:
"description",
"custom_contribution_types",
"geometry",
"url",
)


Expand Down

0 comments on commit 5bd2833

Please sign in to comment.