|
@@ -47,6 +47,23 @@ class ResourceInUseFilter(admin.SimpleListFilter):
|
|
|
return queryset.filter(available_filter)
|
|
|
|
|
|
|
|
|
+class ActiveServiceFilter(admin.SimpleListFilter):
|
|
|
+ title = 'actif'
|
|
|
+ parameter_name = 'active'
|
|
|
+
|
|
|
+ def lookups(self, request, model_admin):
|
|
|
+ return (
|
|
|
+ (1, 'Actif'),
|
|
|
+ (0, 'Inactif'),
|
|
|
+ )
|
|
|
+
|
|
|
+ def queryset(self, request, queryset):
|
|
|
+ if self.value() == '0': # inactif
|
|
|
+ return queryset.filter(active=False)
|
|
|
+ if self.value() == '1': # actif
|
|
|
+ return queryset.filter(active=True)
|
|
|
+
|
|
|
+
|
|
|
class RouteFilter(admin.SimpleListFilter):
|
|
|
title = 'route'
|
|
|
parameter_name = 'route'
|
|
@@ -184,15 +201,15 @@ ends_resource.short_description = 'Terminer les allocations sélectionnées'
|
|
|
### ModelAdmin
|
|
|
|
|
|
class ServiceAdmin(admin.ModelAdmin):
|
|
|
- list_display = ('id', 'get_adhesion_link', 'get_adherent_link', 'service_type', 'label', 'active')
|
|
|
+ list_display = ('id', 'get_adhesion_link', 'get_adherent_link', 'service_type', 'label', 'is_active',)
|
|
|
list_select_related = ('adhesion', 'adhesion__user', 'adhesion__user__profile', 'adhesion__corporation', 'service_type')
|
|
|
list_filter = (
|
|
|
- 'active',
|
|
|
+ ActiveServiceFilter,
|
|
|
('service_type', admin.RelatedOnlyFieldListFilter),
|
|
|
)
|
|
|
inlines = (ServiceAllocationInline,)
|
|
|
search_fields = ('=id', 'service_type__name', 'label', 'notes',)
|
|
|
- fields = ('adhesion', 'service_type', 'label', 'notes', 'active', 'get_contribution_link',)
|
|
|
+ fields = ('adhesion', 'service_type', 'label', 'notes', 'get_contribution_link',)
|
|
|
readonly_fields = ('get_contribution_link',)
|
|
|
raw_id_fields = ('adhesion',)
|
|
|
|