|
|
|
@ -76,55 +76,55 @@ class HadisAdminForm(forms.ModelForm): |
|
|
|
} |
|
|
|
|
|
|
|
# Schema for explanations JSON field (array of objects with title and description) |
|
|
|
explanations_schema = { |
|
|
|
"type": "array", |
|
|
|
"title": "Explanations", |
|
|
|
"items": { |
|
|
|
"type": "object", |
|
|
|
"title": "Explanation", |
|
|
|
"properties": { |
|
|
|
"language_code": { |
|
|
|
"type": "string", |
|
|
|
"title": "Language Code", |
|
|
|
"enum": ["en", "fa", "ar", "ur", "ru"], |
|
|
|
"options": { |
|
|
|
"enum_titles": ["English", "Persian", "Arabic", "Urdu", "Russian"] |
|
|
|
} |
|
|
|
}, |
|
|
|
"title": { |
|
|
|
"type": "string", |
|
|
|
"title": "Title" |
|
|
|
}, |
|
|
|
"description": { |
|
|
|
"type": "string", |
|
|
|
"title": "Description" |
|
|
|
} |
|
|
|
}, |
|
|
|
"required": ["language_code", "title", "description"] |
|
|
|
} |
|
|
|
} |
|
|
|
# explanations_schema = { |
|
|
|
# "type": "array", |
|
|
|
# "title": "Explanations", |
|
|
|
# "items": { |
|
|
|
# "type": "object", |
|
|
|
# "title": "Explanation", |
|
|
|
# "properties": { |
|
|
|
# "language_code": { |
|
|
|
# "type": "string", |
|
|
|
# "title": "Language Code", |
|
|
|
# "enum": ["en", "fa", "ar", "ur", "ru"], |
|
|
|
# "options": { |
|
|
|
# "enum_titles": ["English", "Persian", "Arabic", "Urdu", "Russian"] |
|
|
|
# } |
|
|
|
# }, |
|
|
|
# "title": { |
|
|
|
# "type": "string", |
|
|
|
# "title": "Title" |
|
|
|
# }, |
|
|
|
# "description": { |
|
|
|
# "type": "string", |
|
|
|
# "title": "Description" |
|
|
|
# } |
|
|
|
# }, |
|
|
|
# "required": ["language_code", "title", "description"] |
|
|
|
# } |
|
|
|
# } |
|
|
|
|
|
|
|
# Schema for address_details JSON field (array of objects with text and priority) |
|
|
|
address_details_schema = { |
|
|
|
"type": "array", |
|
|
|
"title": "Address Details", |
|
|
|
"items": { |
|
|
|
"type": "object", |
|
|
|
"title": "Address Detail", |
|
|
|
"properties": { |
|
|
|
"text": { |
|
|
|
"type": "string", |
|
|
|
"title": "Address Text" |
|
|
|
}, |
|
|
|
"priority": { |
|
|
|
"type": "integer", |
|
|
|
"title": "Priority", |
|
|
|
"minimum": 0 |
|
|
|
} |
|
|
|
}, |
|
|
|
"required": ["text", "priority"] |
|
|
|
} |
|
|
|
} |
|
|
|
# address_details_schema = { |
|
|
|
# "type": "array", |
|
|
|
# "title": "Address Details", |
|
|
|
# "items": { |
|
|
|
# "type": "object", |
|
|
|
# "title": "Address Detail", |
|
|
|
# "properties": { |
|
|
|
# "text": { |
|
|
|
# "type": "string", |
|
|
|
# "title": "Address Text" |
|
|
|
# }, |
|
|
|
# "priority": { |
|
|
|
# "type": "integer", |
|
|
|
# "title": "Priority", |
|
|
|
# "minimum": 0 |
|
|
|
# } |
|
|
|
# }, |
|
|
|
# "required": ["text", "priority"] |
|
|
|
# } |
|
|
|
# } |
|
|
|
|
|
|
|
# Apply JSON editor widgets |
|
|
|
self.fields['translation'].widget = JsonEditorWidget(attrs={ |
|
|
|
@ -137,15 +137,15 @@ class HadisAdminForm(forms.ModelForm): |
|
|
|
'title': 'Links' |
|
|
|
}) |
|
|
|
|
|
|
|
self.fields['explanations'].widget = JsonEditorWidget(attrs={ |
|
|
|
'schema': json.dumps(explanations_schema), |
|
|
|
'title': 'Explanations' |
|
|
|
}) |
|
|
|
# self.fields['explanations'].widget = JsonEditorWidget(attrs={ |
|
|
|
# 'schema': json.dumps(explanations_schema), |
|
|
|
# 'title': 'Explanations' |
|
|
|
# }) |
|
|
|
|
|
|
|
self.fields['address_details'].widget = JsonEditorWidget(attrs={ |
|
|
|
'schema': json.dumps(address_details_schema), |
|
|
|
'title': 'Address Details' |
|
|
|
}) |
|
|
|
# self.fields['address_details'].widget = JsonEditorWidget(attrs={ |
|
|
|
# 'schema': json.dumps(address_details_schema), |
|
|
|
# 'title': 'Address Details' |
|
|
|
# }) |
|
|
|
|
|
|
|
|
|
|
|
# Inline Admin Classes |
|
|
|
@ -201,26 +201,26 @@ class HadisStatusAdmin(ModelAdmin): |
|
|
|
class HadisAdmin(ModelAdmin): |
|
|
|
"""Admin for Hadis model""" |
|
|
|
form = HadisAdminForm |
|
|
|
list_display = ('number', 'title', 'category', 'status', 'hadis_status', 'created_at') |
|
|
|
list_display = ('number', 'title', 'category', 'status', 'hadis_status', 'created_at','slug') |
|
|
|
list_filter = ('status', 'hadis_status', 'category', 'created_at') |
|
|
|
search_fields = ('title', 'text', 'category__title') |
|
|
|
readonly_fields = ('created_at', 'updated_at', 'share_link') |
|
|
|
search_fields = ('title', 'text', 'category__title', 'slug') |
|
|
|
readonly_fields = ('created_at', 'updated_at', 'share_link', 'slug') |
|
|
|
ordering = ('category', 'number') |
|
|
|
inlines = [HadisReferenceInline] |
|
|
|
filter_horizontal = ('tags',) |
|
|
|
|
|
|
|
fieldsets = ( |
|
|
|
(None, { |
|
|
|
'fields': ('category', 'number', 'title', 'status') |
|
|
|
'fields': ('category', 'number', 'title', 'status', 'slug') |
|
|
|
}), |
|
|
|
(_('Content'), { |
|
|
|
'fields': ('text', 'translation', 'explanation', 'explanations') |
|
|
|
'fields': ('text', 'translation', 'explanation') |
|
|
|
}), |
|
|
|
(_('Status & Classification'), { |
|
|
|
'fields': ('hadis_status', 'hadis_status_text', 'tags') |
|
|
|
}), |
|
|
|
(_('Additional Information'), { |
|
|
|
'fields': ('address', 'address_details', 'links', 'share_link'), |
|
|
|
'fields': ('address', 'links', 'share_link'), |
|
|
|
'classes': ('collapse',) |
|
|
|
}), |
|
|
|
(_('Timestamps'), { |
|
|
|
|