Add read-only admin functionality and enhance billing models in admin interface
This commit is contained in:
@@ -4,7 +4,13 @@ Billing Module Admin
|
||||
from django.contrib import admin
|
||||
from django.utils.html import format_html
|
||||
from igny8_core.admin.base import AccountAdminMixin
|
||||
from igny8_core.business.billing.models import CreditCostConfig
|
||||
from igny8_core.business.billing.models import (
|
||||
CreditCostConfig,
|
||||
Invoice,
|
||||
Payment,
|
||||
CreditPackage,
|
||||
PaymentMethodConfig,
|
||||
)
|
||||
from .models import CreditTransaction, CreditUsageLog, AccountPaymentMethod
|
||||
|
||||
|
||||
@@ -44,6 +50,56 @@ class CreditUsageLogAdmin(AccountAdminMixin, admin.ModelAdmin):
|
||||
get_account_display.short_description = 'Account'
|
||||
|
||||
|
||||
@admin.register(Invoice)
|
||||
class InvoiceAdmin(AccountAdminMixin, admin.ModelAdmin):
|
||||
list_display = [
|
||||
'invoice_number',
|
||||
'account',
|
||||
'status',
|
||||
'total',
|
||||
'currency',
|
||||
'invoice_date',
|
||||
'due_date',
|
||||
'subscription',
|
||||
]
|
||||
list_filter = ['status', 'currency', 'invoice_date', 'account']
|
||||
search_fields = ['invoice_number', 'account__name', 'subscription__id']
|
||||
readonly_fields = ['created_at', 'updated_at']
|
||||
|
||||
|
||||
@admin.register(Payment)
|
||||
class PaymentAdmin(AccountAdminMixin, admin.ModelAdmin):
|
||||
list_display = [
|
||||
'id',
|
||||
'invoice',
|
||||
'account',
|
||||
'payment_method',
|
||||
'status',
|
||||
'amount',
|
||||
'currency',
|
||||
'processed_at',
|
||||
]
|
||||
list_filter = ['status', 'payment_method', 'currency', 'created_at']
|
||||
search_fields = ['invoice__invoice_number', 'account__name', 'stripe_payment_intent_id', 'paypal_order_id']
|
||||
readonly_fields = ['created_at', 'updated_at']
|
||||
|
||||
|
||||
@admin.register(CreditPackage)
|
||||
class CreditPackageAdmin(admin.ModelAdmin):
|
||||
list_display = ['name', 'slug', 'credits', 'price', 'discount_percentage', 'is_active', 'is_featured', 'sort_order']
|
||||
list_filter = ['is_active', 'is_featured']
|
||||
search_fields = ['name', 'slug']
|
||||
readonly_fields = ['created_at', 'updated_at']
|
||||
|
||||
|
||||
@admin.register(PaymentMethodConfig)
|
||||
class PaymentMethodConfigAdmin(admin.ModelAdmin):
|
||||
list_display = ['country_code', 'payment_method', 'is_enabled', 'display_name', 'sort_order']
|
||||
list_filter = ['payment_method', 'is_enabled', 'country_code']
|
||||
search_fields = ['country_code', 'display_name', 'payment_method']
|
||||
readonly_fields = ['created_at', 'updated_at']
|
||||
|
||||
|
||||
@admin.register(AccountPaymentMethod)
|
||||
class AccountPaymentMethodAdmin(AccountAdminMixin, admin.ModelAdmin):
|
||||
list_display = [
|
||||
|
||||
@@ -91,3 +91,20 @@ class AISettingsAdmin(AccountAdminMixin, admin.ModelAdmin):
|
||||
return '-'
|
||||
get_account_display.short_description = 'Account'
|
||||
|
||||
|
||||
@admin.register(ModuleEnableSettings)
|
||||
class ModuleEnableSettingsAdmin(AccountAdminMixin, admin.ModelAdmin):
|
||||
list_display = [
|
||||
'account',
|
||||
'planner_enabled',
|
||||
'writer_enabled',
|
||||
'thinker_enabled',
|
||||
'automation_enabled',
|
||||
'site_builder_enabled',
|
||||
'linker_enabled',
|
||||
'optimizer_enabled',
|
||||
'publisher_enabled',
|
||||
]
|
||||
list_filter = ['planner_enabled', 'writer_enabled', 'thinker_enabled', 'automation_enabled', 'site_builder_enabled', 'linker_enabled', 'optimizer_enabled', 'publisher_enabled']
|
||||
search_fields = ['account__name']
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from django.contrib import admin
|
||||
from igny8_core.admin.base import SiteSectorAdminMixin
|
||||
from .models import Tasks, Images, Content
|
||||
from igny8_core.business.content.models import ContentTaxonomy, ContentAttribute, ContentTaxonomyRelation
|
||||
from igny8_core.business.content.models import ContentTaxonomy, ContentAttribute, ContentTaxonomyRelation, ContentClusterMap
|
||||
|
||||
|
||||
class ContentTaxonomyInline(admin.TabularInline):
|
||||
@@ -223,3 +223,18 @@ class ContentAttributeAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
|
||||
qs = super().get_queryset(request)
|
||||
return qs.select_related('content', 'cluster', 'site', 'sector')
|
||||
|
||||
|
||||
@admin.register(ContentTaxonomyRelation)
|
||||
class ContentTaxonomyRelationAdmin(admin.ModelAdmin):
|
||||
list_display = ['content', 'taxonomy', 'created_at']
|
||||
search_fields = ['content__title', 'taxonomy__name']
|
||||
readonly_fields = ['created_at', 'updated_at']
|
||||
|
||||
|
||||
@admin.register(ContentClusterMap)
|
||||
class ContentClusterMapAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
|
||||
list_display = ['content', 'task', 'cluster', 'role', 'source', 'site', 'sector', 'created_at']
|
||||
list_filter = ['role', 'source', 'site', 'sector']
|
||||
search_fields = ['content__title', 'task__title', 'cluster__name']
|
||||
readonly_fields = ['created_at', 'updated_at']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user