Browse Source

fix liens services

Élie Bouttier 7 years ago
parent
commit
68572cd4ed
2 changed files with 5 additions and 2 deletions
  1. 1 0
      adhesions/models.py
  2. 4 2
      services/admin.py

+ 1 - 0
adhesions/models.py

@@ -69,6 +69,7 @@ class Adhesion(models.Model):
     def get_adhesion_link(self):
         url = reverse('admin:adhesions_adhesion_change', args=(self.id,))
         return format_html(u'<a href="{}">ADT{}</a>', url, str(self.id))
+    get_adhesion_link.short_description = 'Numéro d’adhérent'
 
     def __str__(self):
         return 'ADT%d' % self.id

+ 4 - 2
services/admin.py

@@ -102,8 +102,7 @@ ends_resource.short_description = 'Terminer les allocations sélectionnées'
 ### ModelAdmin
 
 class ServiceAdmin(admin.ModelAdmin):
-    list_display = ('id', 'adhesion', 'get_adherent_link', 'service_type', 'label', 'active')
-    list_display_links = ('adhesion',)
+    list_display = ('id', 'get_adhesion_link', 'get_adherent_link', 'service_type', 'label', 'active')
     list_select_related = ('adhesion',) # to reduce database requests
     list_filter = (
         'active',
@@ -113,6 +112,9 @@ class ServiceAdmin(admin.ModelAdmin):
     search_fields = ('id', 'service_type__name', 'label', 'adhesion__id',)
     raw_id_fields = ('adhesion',)
 
+    get_adhesion_link = lambda self, service: service.adhesion.get_adhesion_link()
+    get_adhesion_link.short_description = Adhesion.get_adhesion_link.short_description
+
     get_adherent_link = lambda self, service: service.adhesion.get_adherent_link()
     get_adherent_link.short_description = Adhesion.get_adherent_link.short_description