update
This commit is contained in:
38
gnx-react/backend/policies/admin.py
Normal file
38
gnx-react/backend/policies/admin.py
Normal file
@@ -0,0 +1,38 @@
|
||||
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',)}
|
||||
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']
|
||||
|
||||
Reference in New Issue
Block a user