| from django.contrib import admin
|
| from .models import MasterQuestion, PropertyQA, AgencyAutoChatSetting, PropertyAutoChatState, GlobalQA, PropertyCustomQA
|
|
|
| @admin.register(GlobalQA)
|
| class GlobalQAAdmin(admin.ModelAdmin):
|
| list_display = ['question', 'answer_preview', 'language', 'priority', 'is_active']
|
| list_filter = ['language', 'is_active', 'priority']
|
| search_fields = ['question', 'answer']
|
| list_editable = ['priority', 'is_active']
|
|
|
| def answer_preview(self, obj):
|
| return obj.answer[:50]
|
| answer_preview.short_description = 'Answer'
|
|
|
| fieldsets = (
|
| ('Question & Answer', {
|
| 'fields': ('question', 'answer', 'language')
|
| }),
|
| ('Settings', {
|
| 'fields': ('priority', 'is_active'),
|
| 'description': 'Higher priority = checked first for matching'
|
| }),
|
| )
|
|
|
| @admin.register(MasterQuestion)
|
| class MasterQuestionAdmin(admin.ModelAdmin):
|
| list_display = ['question', 'order', 'is_active']
|
| list_editable = ['order', 'is_active']
|
| search_fields = ['question']
|
|
|
| @admin.register(PropertyQA)
|
| class PropertyQAAdmin(admin.ModelAdmin):
|
| list_display = ['property', 'question_preview', 'answer_preview']
|
| list_filter = ['agency']
|
| search_fields = ['answer']
|
|
|
| def question_preview(self, obj):
|
| return obj.question_text[:50]
|
| question_preview.short_description = 'Question'
|
|
|
| def answer_preview(self, obj):
|
| return obj.answer[:50]
|
| answer_preview.short_description = 'Answer'
|
|
|
| @admin.register(AgencyAutoChatSetting)
|
| class AgencyAutoChatSettingAdmin(admin.ModelAdmin):
|
| list_display = ['agency', 'is_enabled', 'delay_seconds', 'confidence_threshold']
|
| list_filter = ['is_enabled']
|
| list_editable = ['delay_seconds', 'confidence_threshold']
|
|
|
| @admin.register(PropertyAutoChatState)
|
| class PropertyAutoChatStateAdmin(admin.ModelAdmin):
|
| list_display = ['property', 'is_auto_chat_enabled', 'total_auto_replies', 'last_auto_reply_at']
|
| list_filter = ['is_auto_chat_enabled']
|
| readonly_fields = ['total_auto_replies', 'last_auto_reply_at']
|
|
|
| @admin.register(PropertyCustomQA)
|
| class PropertyCustomQAAdmin(admin.ModelAdmin):
|
| list_display = ['property', 'agency', 'order', 'question_preview', 'is_active']
|
| list_filter = ['agency', 'is_active', 'property']
|
| search_fields = ['question', 'answer']
|
| list_editable = ['is_active']
|
|
|
| def question_preview(self, obj):
|
| return obj.question[:60]
|
| question_preview.short_description = 'Question'
|
|
|
| readonly_fields = ['question_embedding'] |