Browse Source

List the offers subscribed by members on the admin member detail view

Grégoire Jadi 8 years ago
parent
commit
28a18e502b
1 changed files with 16 additions and 2 deletions
  1. 16 2
      coin/members/admin.py

+ 16 - 2
coin/members/admin.py

@@ -11,7 +11,8 @@ from django.conf.urls import url
 from django.db.models.query import QuerySet
 from django.core.urlresolvers import reverse
 
-from coin.members.models import Member, CryptoKey, LdapUser, MembershipFee
+from coin.members.models import (
+    Member, CryptoKey, LdapUser, MembershipFee, OfferSubscription)
 from coin.members.membershipfee_filter import MembershipFeeFilter
 from coin.members.forms import MemberChangeForm, MemberCreationForm
 from coin.utils import delete_selected
@@ -30,6 +31,19 @@ class MembershipFeeInline(admin.TabularInline):
               'reference', 'payment_date')
 
 
+class OfferSubscriptionInline(admin.TabularInline):
+    model = OfferSubscription
+    extra = 0
+    readonly_fields = ('subscription_date', 'resign_date', 'commitment',
+                       'offer')
+
+    def has_add_permission(self, request, obj=None):
+        return False
+
+    def has_delete_permission(self, request, obj=None):
+        return False
+
+
 class MemberAdmin(UserAdmin):
     list_display = ('id', 'status', 'username', 'first_name', 'last_name',
                     'nickname', 'organization_name', 'email',
@@ -85,7 +99,7 @@ class MemberAdmin(UserAdmin):
 
     save_on_top = True
 
-    inlines = [CryptoKeyInline, MembershipFeeInline]
+    inlines = [CryptoKeyInline, MembershipFeeInline, OfferSubscriptionInline]
 
     def get_readonly_fields(self, request, obj=None):
         if obj: