# Admin Dashboard The `subscriptions` package includes a rich admin interface built with [Django Unfold](https://github.com/unfoldadmin/django-unfold), providing a modern admin experience for managing subscriptions. ## Features - **Color-coded status badges** for subscriptions, payments, invoices - **Custom actions** (activate/deactivate plans, cancel/pause subscriptions, retry payments) - **Inline displays** (payments and invoices shown within subscription detail) - **Advanced filters** (dropdown filters, date range filters) - **Search** across users, emails, order IDs, plan names - **Raw ID fields** for User foreign keys (handles large user tables) ## Registered Models ### Plans | Display Column | Description | |---------------|-------------| | Name | Plan name | | Price | Formatted with currency | | Interval | Human-readable interval (e.g., "Every 1 month(s)") | | Status | Color badge (green=active, yellow=inactive, red=archived) | | Subscribers | Count of active subscribers | | Trial Days | Trial period | | Sort Order | Display ordering | **Actions:** Activate Plans, Deactivate Plans ### Subscriptions | Display Column | Description | |---------------|-------------| | User | Subscriber username | | Plan | Plan name with link | | Status | Color badge | | Payment Type | Badge | | Period | Start → End | | Billing Cycles | Count | | Next Billing | Date | **Inlines:** Payments, Invoices **Actions:** Cancel, Pause (available via custom admin actions) ### Payments | Display Column | Description | |---------------|-------------| | Order ID | Midtrans order ID | | User | Payer | | Type | Payment method badge | | Status | Color badge | | Amount | Formatted with currency | | Created | Timestamp | ### Invoices **Inlines:** Invoice Items Displays invoice number, status badge, amounts, dates, billing period. ### Webhook Logs Displays order ID, transaction status, processing status badge, IP address, payload (expandable). ### Notification Logs Displays notification type, channel, status, recipient, sent timestamp. ### Wallets Displays user, balance, currency, active status. ### Wallet Transactions Displays wallet, transaction type, signed amount, balance before/after, description. ### Top-Ups Displays order ID, user, amount, payment type, status badge. ## Admin Navigation The Django Unfold sidebar is configured with grouped navigation: - **Dashboard** — Admin home - **Subscriptions** — Plans, Subscriptions, Payments, Invoices - **Wallet** — Wallets, Wallet Transactions, Top Ups - **Notifications** — Webhook Logs, Notification Logs - **Users & Auth** — Users, Groups (superuser only) - **Celery** — Periodic Tasks, Intervals, Crontabs ## Customization ### Override Admin Classes You can unregister and re-register models with custom admin classes: ```python from django.contrib import admin from subscriptions.models import Plan from subscriptions.admin import PlanAdmin admin.site.unregister(Plan) @admin.register(Plan) class CustomPlanAdmin(PlanAdmin): list_display = PlanAdmin.list_display + ["created_at"] ``` ### Unfold Configuration The Unfold theme is configured in `settings.py` under the `UNFOLD` dictionary. See the [Django Unfold documentation](https://unfoldadmin.com/) for customization options.