194 lines
7.4 KiB
Python
194 lines
7.4 KiB
Python
"""
|
|
Custom AdminSite for IGNY8 to organize models into proper groups
|
|
"""
|
|
from django.contrib import admin
|
|
from django.contrib.admin.apps import AdminConfig
|
|
from django.apps import apps
|
|
from django.urls import path
|
|
from django.shortcuts import redirect
|
|
|
|
|
|
class Igny8AdminSite(admin.AdminSite):
|
|
"""
|
|
Custom AdminSite that organizes models into the planned groups:
|
|
1. Billing & Tenancy
|
|
2. Sites & Users
|
|
3. Global Reference Data
|
|
4. Planner
|
|
5. Writer Module
|
|
6. Thinker Module
|
|
7. System Configuration
|
|
"""
|
|
site_header = 'IGNY8 Administration'
|
|
site_title = 'IGNY8 Admin'
|
|
index_title = 'IGNY8 Administration'
|
|
|
|
def get_urls(self):
|
|
"""Add dashboard URL"""
|
|
urls = super().get_urls()
|
|
custom_urls = [
|
|
path('dashboard/', self.dashboard_view, name='dashboard'),
|
|
]
|
|
return custom_urls + urls
|
|
|
|
def dashboard_view(self, request):
|
|
"""Dashboard view wrapper"""
|
|
from igny8_core.admin.dashboard import admin_dashboard
|
|
return admin_dashboard(request)
|
|
|
|
def get_app_list(self, request):
|
|
"""
|
|
Customize the app list to organize models into logical groups
|
|
"""
|
|
# Get the default app list
|
|
app_dict = self._build_app_dict(request)
|
|
|
|
# Define our custom groups with their models (using object_name)
|
|
# Organized by business function
|
|
custom_groups = {
|
|
'<i class="fas fa-dollar-sign"></i> BILLING & ACCOUNTS': {
|
|
'models': [
|
|
('igny8_core_auth', 'Plan'),
|
|
('billing', 'PlanLimitUsage'),
|
|
('igny8_core_auth', 'Account'),
|
|
('igny8_core_auth', 'Subscription'),
|
|
('billing', 'Invoice'),
|
|
('billing', 'Payment'),
|
|
('billing', 'CreditTransaction'),
|
|
('billing', 'CreditUsageLog'),
|
|
('billing', 'CreditPackage'),
|
|
('billing', 'PaymentMethodConfig'),
|
|
('billing', 'AccountPaymentMethod'),
|
|
('billing', 'CreditCostConfig'),
|
|
],
|
|
},
|
|
'<i class="fas fa-users"></i> SITES & USERS': {
|
|
'models': [
|
|
('igny8_core_auth', 'Site'),
|
|
('igny8_core_auth', 'Sector'),
|
|
('igny8_core_auth', 'User'),
|
|
('igny8_core_auth', 'SiteUserAccess'),
|
|
('igny8_core_auth', 'PasswordResetToken'),
|
|
],
|
|
},
|
|
'<i class="fas fa-file-alt"></i> CONTENT MANAGEMENT': {
|
|
'models': [
|
|
('writer', 'Content'),
|
|
('writer', 'Tasks'),
|
|
('writer', 'Images'),
|
|
('writer', 'ContentTaxonomy'),
|
|
('writer', 'ContentAttribute'),
|
|
('writer', 'ContentTaxonomyRelation'),
|
|
('writer', 'ContentClusterMap'),
|
|
],
|
|
},
|
|
'<i class="fas fa-lightbulb"></i> PLANNING & STRATEGY': {
|
|
'models': [
|
|
('planner', 'Clusters'),
|
|
('planner', 'Keywords'),
|
|
('planner', 'ContentIdeas'),
|
|
('system', 'Strategy'),
|
|
],
|
|
},
|
|
'<i class="fas fa-plug"></i> INTEGRATIONS & PUBLISHING': {
|
|
'models': [
|
|
('integration', 'SiteIntegration'),
|
|
('integration', 'SyncEvent'),
|
|
('publishing', 'PublishingRecord'),
|
|
('publishing', 'DeploymentRecord'),
|
|
],
|
|
},
|
|
'<i class="fas fa-robot"></i> AI & AUTOMATION': {
|
|
'models': [
|
|
('ai', 'AITaskLog'),
|
|
('system', 'AIPrompt'),
|
|
('automation', 'AutomationConfig'),
|
|
('automation', 'AutomationRun'),
|
|
('optimization', 'OptimizationTask'),
|
|
],
|
|
},
|
|
'<i class="fas fa-globe"></i> GLOBAL REFERENCE DATA': {
|
|
'models': [
|
|
('igny8_core_auth', 'Industry'),
|
|
('igny8_core_auth', 'IndustrySector'),
|
|
('igny8_core_auth', 'SeedKeyword'),
|
|
],
|
|
},
|
|
'<i class="fas fa-cog"></i> SYSTEM CONFIGURATION': {
|
|
'models': [
|
|
('system', 'IntegrationSettings'),
|
|
('system', 'AuthorProfile'),
|
|
('system', 'SystemSettings'),
|
|
('system', 'AccountSettings'),
|
|
('system', 'UserSettings'),
|
|
('system', 'ModuleSettings'),
|
|
('system', 'AISettings'),
|
|
('system', 'ModuleEnableSettings'),
|
|
('system', 'SystemLog'),
|
|
('system', 'SystemStatus'),
|
|
],
|
|
},
|
|
'<i class="fas fa-tasks"></i> MONITORING & TASKS': {
|
|
'models': [
|
|
('django_celery_results', 'TaskResult'),
|
|
('django_celery_results', 'GroupResult'),
|
|
],
|
|
},
|
|
'<i class="fas fa-server"></i> DJANGO SYSTEM': {
|
|
'models': [
|
|
('admin', 'LogEntry'),
|
|
('auth', 'Group'),
|
|
('auth', 'Permission'),
|
|
('contenttypes', 'ContentType'),
|
|
('sessions', 'Session'),
|
|
],
|
|
},
|
|
}
|
|
|
|
# Build the custom app list
|
|
app_list = []
|
|
|
|
for group_name, group_config in custom_groups.items():
|
|
group_models = []
|
|
|
|
for app_label, model_name in group_config['models']:
|
|
# Find the model in app_dict
|
|
if app_label in app_dict:
|
|
app_data = app_dict[app_label]
|
|
# Look for the model in the app's models
|
|
for model in app_data.get('models', []):
|
|
if model['object_name'] == model_name:
|
|
group_models.append(model)
|
|
break
|
|
|
|
# Only add the group if it has models
|
|
if group_models:
|
|
app_list.append({
|
|
'name': group_name,
|
|
'app_label': group_name.lower().replace(' ', '_').replace('&', '').replace('emoji', ''),
|
|
'app_url': None,
|
|
'has_module_perms': True,
|
|
'models': group_models,
|
|
})
|
|
|
|
# Sort the app list by our custom order
|
|
order = [
|
|
'<i class="fas fa-dollar-sign"></i> BILLING & ACCOUNTS',
|
|
'<i class="fas fa-users"></i> SITES & USERS',
|
|
'<i class="fas fa-file-alt"></i> CONTENT MANAGEMENT',
|
|
'<i class="fas fa-lightbulb"></i> PLANNING & STRATEGY',
|
|
'<i class="fas fa-plug"></i> INTEGRATIONS & PUBLISHING',
|
|
'<i class="fas fa-robot"></i> AI & AUTOMATION',
|
|
'<i class="fas fa-globe"></i> GLOBAL REFERENCE DATA',
|
|
'<i class="fas fa-cog"></i> SYSTEM CONFIGURATION',
|
|
'<i class="fas fa-tasks"></i> MONITORING & TASKS',
|
|
'<i class="fas fa-server"></i> DJANGO SYSTEM',
|
|
]
|
|
|
|
app_list.sort(key=lambda x: order.index(x['name']) if x['name'] in order else 999)
|
|
|
|
return app_list
|
|
|
|
|
|
|