#80: Allow admins to mark members having paid their membership

* Add membership column in the admin view of the Accounts model
* Allow the admins to bluk mark accounts as having paid their membership
or not
parent a1ddad32
Pipeline #474 passed with stages
in 4 minutes and 7 seconds
......@@ -4,6 +4,22 @@ from .models import PendingUser
from .models import Account
def mark_paid_membership(model, request, querySet):
accounts = querySet.all()
for account in accounts:
account.has_paid_membership = True
account.save(update_fields=['has_paid_membership'])
def remove_paid_membership(model, request, querySet):
accounts = querySet.all()
for account in accounts:
account.has_paid_membership = False
account.save(update_fields=['has_paid_membership'])
class AccountAdmin(admin.ModelAdmin):
def get_first_name(self, obj):
return obj.user.first_name
......@@ -14,6 +30,12 @@ class AccountAdmin(admin.ModelAdmin):
def get_username(self, obj):
return obj.user.username
def has_paid_membership(self, obj):
return obj.has_paid_membership
# Add a custom action in order to add / remove the membership flag to the accounts
actions = [mark_paid_membership, remove_paid_membership]
get_first_name.admin_order_field = 'user__first_name'
get_first_name.short_description = 'First name'
......@@ -23,7 +45,10 @@ class AccountAdmin(admin.ModelAdmin):
get_username.admin_order_field = 'user__username'
get_username.short_description = 'Username'
list_display = ('get_first_name', 'get_last_name', 'get_username')
has_paid_membership.admin_order_field = 'account__has_paid_membership'
has_paid_membership.short_description = 'Has paid the membership fee?'
list_display = ('get_first_name', 'get_last_name', 'get_username', 'has_paid_membership')
admin.site.register(PendingUser)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment