|
@@ -10,8 +10,10 @@ 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
|
|
|
+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 +32,28 @@ class MembershipFeeInline(admin.TabularInline):
|
|
|
'reference', 'payment_date')
|
|
|
|
|
|
|
|
|
+class OfferSubscriptionInline(admin.TabularInline):
|
|
|
+ model = OfferSubscription
|
|
|
+ extra = 0
|
|
|
+ readonly_fields = ('subscription_date', 'resign_date', 'commitment',
|
|
|
+ '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
|
|
|
+
|
|
|
+ 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 +109,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:
|