From 5055095c6b33fa214c2f3598a01219ca1fdc34c2 Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Sun, 21 Jul 2024 16:10:20 +0200 Subject: [PATCH] Admin for Member model, not for User --- src/accounting/models.py | 2 +- src/membership/admin.py | 28 ++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/accounting/models.py b/src/accounting/models.py index 3d0fb2d..4699076 100644 --- a/src/accounting/models.py +++ b/src/accounting/models.py @@ -150,7 +150,7 @@ class Payment(CreatedModifiedAbstract): payment_type = models.ForeignKey("PaymentType", on_delete=models.PROTECT) external_transaction_id = models.CharField(max_length=255, default="", blank=True) - # stripe_charge_id = models.CharField(max_length=255, null=True, blank=True) # noqa: ERA001 + stripe_charge_id = models.CharField(max_length=255, default="", blank=True) class Meta: verbose_name = _("payment") diff --git a/src/membership/admin.py b/src/membership/admin.py index 2cf7030..6fdb423 100644 --- a/src/membership/admin.py +++ b/src/membership/admin.py @@ -1,22 +1,38 @@ """Admin configuration for membership app.""" from django.contrib import admin +from django.contrib.auth.admin import UserAdmin +from django.contrib.auth.models import User -from .models import Membership -from .models import MembershipType -from .models import SubscriptionPeriod +from . import models + +# Do not use existing user admin +admin.site.unregister(User) -@admin.register(Membership) +@admin.register(models.Membership) class MembershipAdmin(admin.ModelAdmin): """Admin for Membership model.""" -@admin.register(MembershipType) +@admin.register(models.MembershipType) class MembershipTypeAdmin(admin.ModelAdmin): """Admin for MembershipType model.""" -@admin.register(SubscriptionPeriod) +@admin.register(models.SubscriptionPeriod) class SubscriptionPeriodAdmin(admin.ModelAdmin): """Admin for SubscriptionPeriod model.""" + + +class MembershipInlineAdmin(admin.TabularInline): + """Inline admin.""" + + model = models.Membership + + +@admin.register(models.Member) +class MemberAdmin(UserAdmin): + """Member admin is actually an admin for User objects.""" + + inlines = (MembershipInlineAdmin,)