Skip to content

Commit

Permalink
Merge pull request #258 from Georiviere/improve_admin_customcontribution
Browse files Browse the repository at this point in the history
Improve admin customcontribution
  • Loading branch information
babastienne authored May 3, 2024
2 parents e0cc217 + f75addc commit b77e5e6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion georiviere/contribution/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class CustomContribAttachmentInline(GenericTabularInline):

@admin.register(models.CustomContribution)
class CustomContributionAdmin(LeafletGeoAdmin, admin.ModelAdmin):
list_display = ("custom_type", "portal", "validated", "date_insert", "date_update")
list_display = ("custom_type", "portal", "validated", "contributed_at", "date_insert", "date_update")
list_filter = ("custom_type", "portal", "validated")
form = forms.CustomContributionForm
inlines = [CustomContribAttachmentInline]
Expand Down
10 changes: 7 additions & 3 deletions georiviere/portal/views/contribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,6 @@ class CustomContributionViewSet(
mixins.ListModelMixin,
viewsets.GenericViewSet,
):
queryset = CustomContribution.objects.filter(validated=True).annotate(
geometry=Transform(F("geom"), settings.API_SRID)
).prefetch_related("attachments")
serializer_class = CustomContributionSerializer
geojson_serializer_class = CustomContributionGeoJSONSerializer
renderer_classes = (
Expand All @@ -311,6 +308,13 @@ class CustomContributionViewSet(
permission_classes = [permissions.AllowAny]
pagination_class = LimitOffsetPagination

def get_queryset(self):
portal_pk = self.kwargs["portal_pk"]
queryset = CustomContribution.objects.filter(portal_id=portal_pk, validated=True).annotate(
geometry=Transform(F("geom"), settings.API_SRID)
).prefetch_related("attachments")
return queryset

def retrieve(self, request, *args, **kwargs):
""" Customize retrieve method to add custom type values to the response"""
object = self.get_object()
Expand Down
Binary file added georiviere/static/images/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b77e5e6

Please sign in to comment.