2022-10-13 14:26:43 +00:00
|
|
|
from django.contrib import admin
|
|
|
|
from django.contrib.auth.admin import UserAdmin
|
2022-10-15 20:51:47 +00:00
|
|
|
from django_otp.admin import OTPAdminSite
|
2022-10-13 14:26:43 +00:00
|
|
|
|
|
|
|
from .forms import CustomUserCreationForm
|
|
|
|
from .models import Plan, Session, User
|
|
|
|
|
2022-10-15 20:51:47 +00:00
|
|
|
admin.site.__class__ = OTPAdminSite
|
|
|
|
|
|
|
|
# otp_admin_site = OTPAdminSite(OTPAdminSite.name)
|
|
|
|
# for model_cls, model_admin in admin.site._registry.items():
|
|
|
|
# otp_admin_site.register(model_cls, model_admin.__class__)
|
|
|
|
|
2022-10-13 14:26:43 +00:00
|
|
|
|
|
|
|
# Register your models here.
|
|
|
|
class CustomUserAdmin(UserAdmin):
|
|
|
|
list_filter = ["plans"]
|
|
|
|
model = User
|
|
|
|
add_form = CustomUserCreationForm
|
|
|
|
fieldsets = (
|
|
|
|
*UserAdmin.fieldsets,
|
|
|
|
(
|
|
|
|
"Stripe information",
|
|
|
|
{"fields": ("stripe_id",)},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"Payment information",
|
|
|
|
{
|
|
|
|
"fields": (
|
|
|
|
"plans",
|
|
|
|
"last_payment",
|
|
|
|
)
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
admin.site.register(User, CustomUserAdmin)
|
|
|
|
admin.site.register(Plan)
|
|
|
|
admin.site.register(Session)
|