Register GlobalModuleSettings in admin
This commit is contained in:
@@ -5,6 +5,7 @@ from django.contrib import admin
|
|||||||
from unfold.admin import ModelAdmin
|
from unfold.admin import ModelAdmin
|
||||||
from igny8_core.admin.base import AccountAdminMixin, Igny8ModelAdmin
|
from igny8_core.admin.base import AccountAdminMixin, Igny8ModelAdmin
|
||||||
from .models import AIPrompt, IntegrationSettings, AuthorProfile, Strategy
|
from .models import AIPrompt, IntegrationSettings, AuthorProfile, Strategy
|
||||||
|
from .global_settings_models import GlobalModuleSettings
|
||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from import_export.admin import ExportMixin, ImportExportMixin
|
from import_export.admin import ExportMixin, ImportExportMixin
|
||||||
@@ -312,4 +313,41 @@ class StrategyAdmin(ImportExportMixin, AccountAdminMixin, Igny8ModelAdmin):
|
|||||||
strategy_copy.save()
|
strategy_copy.save()
|
||||||
count += 1
|
count += 1
|
||||||
self.message_user(request, f'{count} strategy/strategies cloned.', messages.SUCCESS)
|
self.message_user(request, f'{count} strategy/strategies cloned.', messages.SUCCESS)
|
||||||
bulk_clone.short_description = 'Clone selected strategies'
|
bulk_clone.short_description = 'Clone selected strategies'
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(GlobalModuleSettings)
|
||||||
|
class GlobalModuleSettingsAdmin(ModelAdmin):
|
||||||
|
"""Admin for Global Module Settings (Singleton)"""
|
||||||
|
|
||||||
|
list_display = [
|
||||||
|
'id',
|
||||||
|
'planner_enabled',
|
||||||
|
'writer_enabled',
|
||||||
|
'thinker_enabled',
|
||||||
|
'automation_enabled',
|
||||||
|
'site_builder_enabled',
|
||||||
|
'linker_enabled',
|
||||||
|
]
|
||||||
|
|
||||||
|
fieldsets = (
|
||||||
|
('Module Toggles', {
|
||||||
|
'fields': (
|
||||||
|
'planner_enabled',
|
||||||
|
'writer_enabled',
|
||||||
|
'thinker_enabled',
|
||||||
|
'automation_enabled',
|
||||||
|
'site_builder_enabled',
|
||||||
|
'linker_enabled',
|
||||||
|
),
|
||||||
|
'description': 'Platform-wide module enable/disable controls. Changes affect all accounts immediately.'
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
def has_add_permission(self, request):
|
||||||
|
"""Only allow one instance (singleton)"""
|
||||||
|
return not self.model.objects.exists()
|
||||||
|
|
||||||
|
def has_delete_permission(self, request, obj=None):
|
||||||
|
"""Prevent deletion of singleton"""
|
||||||
|
return False
|
||||||
Reference in New Issue
Block a user