|
@@ -46,8 +46,8 @@ class ServiceInline(admin.StackedInline):
|
|
|
model = Service
|
|
|
extra = 0
|
|
|
show_change_link = True
|
|
|
- fields = ('service_type', 'label', 'is_active',)
|
|
|
- readonly_fields = ('service_type', 'label', 'is_active',)
|
|
|
+ fields = ('service_type', 'label',)
|
|
|
+ readonly_fields = ('service_type', 'label',)
|
|
|
|
|
|
def has_add_permission(self, request):
|
|
|
return False
|
|
@@ -56,6 +56,20 @@ class ServiceInline(admin.StackedInline):
|
|
|
return False
|
|
|
|
|
|
|
|
|
+class ActiveServiceInline(ServiceInline):
|
|
|
+ verbose_name_plural = 'Services actifs'
|
|
|
+
|
|
|
+ def get_queryset(self, request):
|
|
|
+ return super().get_queryset(request).filter(has_active_allocations=True)
|
|
|
+
|
|
|
+
|
|
|
+class InactiveServiceInline(ServiceInline):
|
|
|
+ verbose_name_plural = 'Anciens services'
|
|
|
+
|
|
|
+ def get_queryset(self, request):
|
|
|
+ return super().get_queryset(request).filter(has_active_allocations=False)
|
|
|
+
|
|
|
+
|
|
|
### Filters
|
|
|
|
|
|
class AdherentTypeFilter(admin.SimpleListFilter):
|
|
@@ -218,7 +232,7 @@ class AdhesionAdmin(AdtSearchMixin, admin.ModelAdmin):
|
|
|
search_fields = ('=id', 'notes',) \
|
|
|
+ tuple(['user__%s' % f for f in UserAdmin.search_fields if 'adhesion' not in f]) \
|
|
|
+ tuple(['corporation__%s' % f for f in CorporationAdmin.search_fields if 'adhesion' not in f])
|
|
|
- inlines = (ServiceInline,)
|
|
|
+ inlines = (ActiveServiceInline, InactiveServiceInline,)
|
|
|
|
|
|
def get_id(self, obj):
|
|
|
return 'ADT%d' % obj.id
|