Browse Source

Show change link to OfferSubscription in OfferSubscriptionInline

Grégoire Jadi 8 years ago
parent
commit
ffcbb166f5
1 changed files with 11 additions and 1 deletions
  1. 11 1
      coin/members/admin.py

+ 11 - 1
coin/members/admin.py

@@ -10,6 +10,7 @@ from django.http import HttpResponseRedirect
 from django.conf.urls import url
 from django.db.models.query import QuerySet
 from django.core.urlresolvers import reverse
+from django.utils.html import format_html
 
 from coin.members.models import (
     Member, CryptoKey, LdapUser, MembershipFee, OfferSubscription)
@@ -35,7 +36,16 @@ class OfferSubscriptionInline(admin.TabularInline):
     model = OfferSubscription
     extra = 0
     readonly_fields = ('subscription_date', 'resign_date', 'commitment',
-                       'offer')
+                       'offer', 'show_change_link')
+
+    # FIXME: Workaround en attendant la migration vers Django >=1.8
+    # À remplacer par InlineModelAdmin.show_change_link = True
+    def show_change_link(self, obj=None):
+        url = reverse('admin:%s_%s_change' % (obj._meta.app_label,
+                                              obj._meta.model_name),
+                      args=[obj.id])
+        return format_html(u'<a href="{}">Éditer</a>', url)
+    show_change_link.short_description = 'Éditer ?'
 
     def has_add_permission(self, request, obj=None):
         return False