|
@@ -5,6 +5,7 @@ from django.utils import timezone
|
|
|
from django.core.urlresolvers import reverse
|
|
|
from django.utils.html import format_html
|
|
|
|
|
|
+from adhesions.models import Adhesion
|
|
|
from .models import Service, ServiceType, IPResource, Route, ResourceAllocation
|
|
|
from djadhere.utils import get_active_filter
|
|
|
|
|
@@ -91,17 +92,20 @@ ends_resource.short_description = 'Terminer les allocations sélectionnées'
|
|
|
### ModelAdmin
|
|
|
|
|
|
class ServiceAdmin(admin.ModelAdmin):
|
|
|
- list_display = ('id', 'adhesion_link', 'service_type', 'label', 'active')
|
|
|
+ list_display = ('id', 'get_adhesion_link', 'get_adherent_link', 'service_type', 'label', 'active')
|
|
|
list_filter = (
|
|
|
'active',
|
|
|
('service_type', admin.RelatedOnlyFieldListFilter),
|
|
|
)
|
|
|
inlines = (AllocationInline,)
|
|
|
- search_fields = ('id', 'service_type__name', 'label')
|
|
|
+ search_fields = ('id', 'service_type__name', 'label', 'adhesion__id',)
|
|
|
raw_id_fields = ('adhesion',)
|
|
|
|
|
|
- adhesion_link = get_foreignkey_link_func('adhesion')
|
|
|
- adhesion_link.short_description = 'Numéro d’adhésion'
|
|
|
+ get_adhesion_link = get_foreignkey_link_func('adhesion')
|
|
|
+ get_adhesion_link.short_description = 'Numéro d’adhésion'
|
|
|
+
|
|
|
+ get_adherent_link = lambda self, service: service.adhesion.get_adherent_link()
|
|
|
+ get_adherent_link.short_description = Adhesion.get_adherent_link.short_description
|
|
|
|
|
|
def get_actions(self, request):
|
|
|
actions = super().get_actions(request)
|