Add multi-plan subscriptions, quotas, and token usage APIs
Implements #16/#17/#36: Founders/Standard/Pro/Business/Backer catalog, Backer email whitelist, prompt-window + token-period gates, and tokens_in/out on conversation/prompt + subscription usage APIs.
This commit is contained in:
+47
-1
@@ -1,6 +1,52 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from finance.models import Invoice, Payment
|
||||
from finance.models import BackerEmail, Invoice, Payment, SubscriptionPlan, UserSubscription
|
||||
|
||||
|
||||
@admin.register(SubscriptionPlan)
|
||||
class SubscriptionPlanAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
"slug",
|
||||
"name",
|
||||
"price_cents",
|
||||
"is_public",
|
||||
"is_selectable",
|
||||
"allows_image_generation",
|
||||
"allows_all_future_features",
|
||||
"prompt_quota_per_window",
|
||||
"prompt_window_hours",
|
||||
"monthly_token_quota",
|
||||
"sort_order",
|
||||
)
|
||||
list_filter = ("is_public", "is_selectable", "allows_image_generation")
|
||||
search_fields = ("slug", "name", "stripe_price_id")
|
||||
readonly_fields = ("created", "last_modified")
|
||||
prepopulated_fields = {"slug": ("name",)}
|
||||
|
||||
|
||||
@admin.register(BackerEmail)
|
||||
class BackerEmailAdmin(admin.ModelAdmin):
|
||||
list_display = ("email", "note", "redeemed_at", "redeemed_user", "created")
|
||||
search_fields = ("email", "note", "redeemed_user__email")
|
||||
raw_id_fields = ("redeemed_user",)
|
||||
readonly_fields = ("created", "last_modified", "redeemed_at", "redeemed_user")
|
||||
|
||||
|
||||
@admin.register(UserSubscription)
|
||||
class UserSubscriptionAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
"user",
|
||||
"plan",
|
||||
"status",
|
||||
"source",
|
||||
"stripe_subscription_id",
|
||||
"monthly_token_quota_override",
|
||||
"created",
|
||||
)
|
||||
list_filter = ("status", "source", "plan")
|
||||
search_fields = ("user__email", "user__username", "stripe_subscription_id")
|
||||
raw_id_fields = ("user", "plan")
|
||||
readonly_fields = ("created", "last_modified")
|
||||
|
||||
|
||||
class PaymentInline(admin.TabularInline):
|
||||
|
||||
Reference in New Issue
Block a user