Browse Source

[enh] Use get_FOO notation instead of global if

ljf 6 years ago
parent
commit
e327322f0c
1 changed files with 10 additions and 5 deletions
  1. 10 5
      coin/members/admin.py

+ 10 - 5
coin/members/admin.py

@@ -84,9 +84,6 @@ class OfferSubscriptionInline(admin.TabularInline):
 
 
 class MemberAdmin(UserAdmin):
-    list_display = ('id', 'status', 'username', 'first_name', 'last_name',
-                    'nickname', 'organization_name', 'email',
-                    'end_date_of_membership')
     list_display_links = ('id', 'username', 'first_name', 'last_name')
     list_filter = ('status', MembershipFeeFilter)
     search_fields = ['username', 'first_name', 'last_name', 'email', 'nickname']
@@ -97,6 +94,16 @@ class MemberAdmin(UserAdmin):
     form = AdminMemberChangeForm
     add_form = MemberCreationForm
 
+    def get_list_display(self, request, obj=None):
+        list_display = ['id', 'status', 'username', 'first_name', 'last_name',
+                        'nickname', 'organization_name', 'email',
+                        'end_date_of_membership']
+
+        if settings.HANDLE_BALANCE:
+            list_display.append('balance')
+
+        return list_display
+
     def get_fieldsets(self, request, obj=None):
         coord_fieldset = ('Coordonnées', {'fields': (
             ('email', 'send_membership_fees_email'),
@@ -257,8 +264,6 @@ class MemberAdmin(UserAdmin):
 
     bulk_send_call_for_membership_fee_email.short_description = 'Envoyer le courriel de relance de cotisation'
 
-if settings.HANDLE_BALANCE:
-    MemberAdmin.list_display.append('balance')
 
 class MembershipFeeAdmin(admin.ModelAdmin):
     list_display = ('member', 'end_date', 'amount', 'payment_method',