You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
1.0 KiB
27 lines
1.0 KiB
from django.contrib import admin
|
|
from unfold.admin import ModelAdmin, TabularInline
|
|
from apps.dynamic_forms.models import FormDefinition, FormResponse
|
|
|
|
|
|
class FormResponseInline(TabularInline):
|
|
model = FormResponse
|
|
extra = 0
|
|
fields = ('user', 'workflow_status', 'created_at')
|
|
readonly_fields = ('created_at',)
|
|
|
|
|
|
@admin.register(FormDefinition)
|
|
class FormDefinitionAdmin(ModelAdmin):
|
|
list_display = ('title', 'slug', 'is_active', 'is_public', 'target_role', 'created_at')
|
|
list_filter = ('is_active', 'is_public', 'created_at')
|
|
search_fields = ('title', 'description', 'slug')
|
|
prepopulated_fields = {'slug': ('title',)}
|
|
inlines = [FormResponseInline]
|
|
|
|
|
|
@admin.register(FormResponse)
|
|
class FormResponseAdmin(ModelAdmin):
|
|
list_display = ('form', 'user', 'workflow_status', 'reviewed_by', 'created_at')
|
|
list_filter = ('workflow_status', 'form', 'created_at')
|
|
search_fields = ('form__title', 'user__email', 'user__fullname', 'admin_notes')
|
|
readonly_fields = ('created_at', 'updated_at')
|