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

* Switch from two actions to directly editable flags in the admin
Accounts table
parent edd362e5
Pipeline #477 passed with stages
in 4 minutes and 5 seconds
......@@ -4,22 +4,6 @@ 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
......@@ -33,9 +17,6 @@ class AccountAdmin(admin.ModelAdmin):
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'
......@@ -50,6 +31,9 @@ class AccountAdmin(admin.ModelAdmin):
list_display = ('get_first_name', 'get_last_name', 'get_username', 'has_paid_membership')
# Allow the 'has_paid_membership' flag to be directly edited in the admin table
list_editable = ('has_paid_membership',)
admin.site.register(PendingUser)
admin.site.register(Account, AccountAdmin)
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