40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
from django.contrib import admin
|
|
from .models import Policy, PolicySection
|
|
|
|
|
|
class PolicySectionInline(admin.TabularInline):
|
|
model = PolicySection
|
|
extra = 1
|
|
fields = ['heading', 'content', 'order', 'is_active']
|
|
|
|
|
|
@admin.register(Policy)
|
|
class PolicyAdmin(admin.ModelAdmin):
|
|
list_display = ['title', 'type', 'version', 'last_updated', 'effective_date', 'is_active']
|
|
list_filter = ['type', 'is_active', 'last_updated']
|
|
search_fields = ['title', 'type', 'description']
|
|
prepopulated_fields = {'slug': ('type',)}
|
|
readonly_fields = ('last_updated',)
|
|
inlines = [PolicySectionInline]
|
|
|
|
fieldsets = (
|
|
('Basic Information', {
|
|
'fields': ('type', 'title', 'slug', 'description')
|
|
}),
|
|
('Version & Dates', {
|
|
'fields': ('version', 'effective_date', 'last_updated')
|
|
}),
|
|
('Status', {
|
|
'fields': ('is_active',)
|
|
}),
|
|
)
|
|
|
|
|
|
@admin.register(PolicySection)
|
|
class PolicySectionAdmin(admin.ModelAdmin):
|
|
list_display = ['policy', 'heading', 'order', 'is_active']
|
|
list_filter = ['policy__type', 'is_active']
|
|
search_fields = ['heading', 'content']
|
|
list_editable = ['order', 'is_active']
|
|
|