Commit a34cd3e7 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

DeletableServiceFilter

parent 8ae0f051
......@@ -80,6 +80,23 @@ class ResourcePingFilter(admin.SimpleListFilter):
return queryset.filter(last_state_up__isnull=True)
class DeletableServiceFilter(admin.SimpleListFilter):
title = "Supprimable"
parameter_name = "deletable"
def lookups(self, request, model_admin):
return (
(1, "Oui"),
(0, "Non"),
)
def queryset(self, request, queryset):
if self.value() == "0":
return queryset.exclude(long_stopped=False)
if self.value() == "1":
return queryset.filter(long_stopped=True)
class ActiveServiceFilter(admin.SimpleListFilter):
title = "actif"
parameter_name = "active"
......@@ -367,6 +384,7 @@ class ServiceAdmin(admin.ModelAdmin):
)
list_filter = (
ActiveServiceFilter,
DeletableServiceFilter,
"loan_equipment",
("service_type", admin.RelatedOnlyFieldListFilter),
)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment