Skip to content

Commit

Permalink
ADS admin: add filter to display deleted entries
Browse files Browse the repository at this point in the history
  • Loading branch information
brmzkw committed Mar 8, 2025
1 parent 473532a commit 58c495c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions mesads/app/admin/ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@ class ADSLegalFileInline(admin.StackedInline):
extra = 0


class ADSDeletedFilter(admin.SimpleListFilter):
title = "Status"
parameter_name = "deleted"

def lookups(self, request, model_admin):
return (
("active", "ADS valides"),
("deleted", "ADS supprimées"),
)

def queryset(self, request, queryset):
if self.value() == "active":
return queryset.filter(deleted_at__isnull=True)
if self.value() == "deleted":
return queryset.filter(deleted_at__isnull=False)
return queryset


@admin.register(ADS)
class ADSAdmin(CompareVersionAdmin):
@admin.display(description="Préfecture")
Expand Down Expand Up @@ -193,6 +211,7 @@ def number_with_deleted_info(self, obj):
ADSUsersCount,
"accepted_cpam",
"vehicle_compatible_pmr",
ADSDeletedFilter,
]

def get_queryset(self, request):
Expand Down

0 comments on commit 58c495c

Please sign in to comment.