Browse Source

Spare some space in members list

By grouping in same column those two:

- last_name (used only for physical persons)
- organization_name (used only for organisations)
Jocelyn Delalande 6 years ago
parent
commit
d239dfff07
1 changed files with 9 additions and 3 deletions
  1. 9 3
      coin/members/admin.py

+ 9 - 3
coin/members/admin.py

@@ -84,10 +84,11 @@ class OfferSubscriptionInline(admin.TabularInline):
 
 
 class MemberAdmin(UserAdmin):
-    list_display = ('id', 'status', 'username', 'first_name', 'last_name',
-                    'nickname', 'organization_name', 'email',
+    list_display = ('id', 'status', 'username', 'first_name',
+                    'name_or_organization_name',
+                    'nickname', 'email',
                     'end_date_of_membership')
-    list_display_links = ('id', 'username', 'first_name', 'last_name')
+    list_display_links = ('id', 'username', 'first_name', 'name_or_organization_name')
     list_filter = ('status', MembershipFeeFilter)
     search_fields = ['username', 'first_name', 'last_name', 'email', 'nickname']
     ordering = ('status', 'username')
@@ -97,6 +98,11 @@ class MemberAdmin(UserAdmin):
     form = AdminMemberChangeForm
     add_form = MemberCreationForm
 
+    def name_or_organization_name(self, obj):
+        """ Used to spare some horizontal space in list view"""
+        return obj.organization_name or obj.last_name
+    name_or_organization_name.short_description = 'Nom'
+
     def get_fieldsets(self, request, obj=None):
         coord_fieldset = ('Coordonnées', {'fields': (
             ('email', 'send_membership_fees_email'),