|
@@ -35,20 +35,23 @@ class MembershipFeeInline(admin.TabularInline):
|
|
|
class OfferSubscriptionInline(admin.TabularInline):
|
|
|
model = OfferSubscription
|
|
|
extra = 0
|
|
|
- readonly_fields = ('get_subscription_reference', '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
|
|
|
+
|
|
|
+ common_fields = ('subscription_date', 'resign_date', 'commitment', 'offer')
|
|
|
+ all_fields = ('get_subscription_reference',) + common_fields
|
|
|
+
|
|
|
+ def get_fields(self, request, obj=None):
|
|
|
+ if obj:
|
|
|
+ return self.all_fields
|
|
|
+ else:
|
|
|
+ return self.common_fields
|
|
|
+
|
|
|
+ def get_readonly_fields(self, request, obj=None):
|
|
|
+ if obj:
|
|
|
+ return self.all_fields
|
|
|
+ else:
|
|
|
+ return ()
|
|
|
+
|
|
|
+ show_change_link = True
|
|
|
|
|
|
def has_delete_permission(self, request, obj=None):
|
|
|
return False
|
|
@@ -82,7 +85,8 @@ class MemberAdmin(UserAdmin):
|
|
|
('username',))})
|
|
|
perm_fieldset = ('Permissions', {'fields': (
|
|
|
('is_active', 'is_staff', 'is_superuser', 'groups'))})
|
|
|
-
|
|
|
+
|
|
|
+ # if obj is null then it is a creation, otherwise it is a modification
|
|
|
if obj:
|
|
|
return (
|
|
|
('Adhérent', {'fields': (
|