81 lines
2.7 KiB
Python
81 lines
2.7 KiB
Python
"""
|
|
Admin configuration for version control models
|
|
"""
|
|
from django.contrib import admin
|
|
from .version_models import ContentVersion, ChecklistItemVersion, ContentChangeLog
|
|
|
|
|
|
@admin.register(ContentVersion)
|
|
class ContentVersionAdmin(admin.ModelAdmin):
|
|
list_display = ['content', 'version_number', 'title_en', 'is_active', 'created_at']
|
|
list_filter = ['is_active', 'role', 'created_at']
|
|
search_fields = ['content__code', 'title_en', 'title_ar']
|
|
readonly_fields = ['version_number', 'created_at', 'updated_at']
|
|
|
|
fieldsets = (
|
|
('Version Info', {
|
|
'fields': ('content', 'version_number', 'created_at')
|
|
}),
|
|
('Content', {
|
|
'fields': ('title_en', 'title_ar', 'description_en', 'description_ar')
|
|
}),
|
|
('Body', {
|
|
'fields': ('content_en', 'content_ar'),
|
|
'classes': ('collapse',)
|
|
}),
|
|
('Configuration', {
|
|
'fields': ('role', 'order', 'is_active')
|
|
}),
|
|
('Change Info', {
|
|
'fields': ('changed_by', 'change_reason')
|
|
}),
|
|
)
|
|
|
|
|
|
@admin.register(ChecklistItemVersion)
|
|
class ChecklistItemVersionAdmin(admin.ModelAdmin):
|
|
list_display = ['checklist_item', 'version_number', 'text_en', 'is_required', 'is_active', 'created_at']
|
|
list_filter = ['is_required', 'is_active', 'role', 'created_at']
|
|
search_fields = ['checklist_item__code', 'text_en', 'text_ar']
|
|
readonly_fields = ['version_number', 'created_at', 'updated_at']
|
|
|
|
fieldsets = (
|
|
('Version Info', {
|
|
'fields': ('checklist_item', 'version_number', 'created_at')
|
|
}),
|
|
('Content', {
|
|
'fields': ('text_en', 'text_ar', 'description_en', 'description_ar')
|
|
}),
|
|
('Configuration', {
|
|
'fields': ('is_required', 'is_active', 'order', 'role', 'content')
|
|
}),
|
|
('Change Info', {
|
|
'fields': ('changed_by', 'change_reason')
|
|
}),
|
|
)
|
|
|
|
|
|
@admin.register(ContentChangeLog)
|
|
class ContentChangeLogAdmin(admin.ModelAdmin):
|
|
list_display = ['action', 'content_type', 'object_code', 'user', 'created_at']
|
|
list_filter = ['action', 'content_type', 'created_at']
|
|
search_fields = ['object_code', 'changes_summary']
|
|
readonly_fields = ['created_at', 'updated_at']
|
|
|
|
fieldsets = (
|
|
('Change Info', {
|
|
'fields': ('action', 'content_type', 'object_id', 'object_code')
|
|
}),
|
|
('Snapshot', {
|
|
'fields': ('snapshot',),
|
|
'classes': ('collapse',)
|
|
}),
|
|
('Details', {
|
|
'fields': ('changes_summary', 'user', 'ip_address')
|
|
}),
|
|
('Metadata', {
|
|
'fields': ('created_at', 'user_agent'),
|
|
'classes': ('collapse',)
|
|
}),
|
|
)
|