This commit is contained in:
IGNY8 VPS (Salman)
2025-11-29 08:59:31 +00:00
parent 4bea79a76d
commit 4237c203b4
18 changed files with 507 additions and 52 deletions

View File

@@ -86,11 +86,12 @@ class ImagesAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
@admin.register(Content)
class ContentAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
list_display = ['title', 'content_type', 'content_structure', 'site', 'sector', 'source', 'status', 'created_at']
list_display = ['title', 'content_type', 'content_structure', 'site', 'sector', 'source', 'status', 'get_taxonomy_count', 'created_at']
list_filter = ['content_type', 'content_structure', 'source', 'status', 'site', 'sector', 'created_at']
search_fields = ['title', 'content_html', 'external_url']
ordering = ['-created_at']
readonly_fields = ['created_at', 'updated_at']
readonly_fields = ['created_at', 'updated_at', 'word_count']
filter_horizontal = ['taxonomy_terms'] # Add many-to-many widget for taxonomy terms
fieldsets = (
('Basic Info', {
@@ -99,8 +100,16 @@ class ContentAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
('Content Classification', {
'fields': ('content_type', 'content_structure', 'source')
}),
('Taxonomy Terms (Tags & Categories)', {
'fields': ('taxonomy_terms',),
'description': 'Select tags and categories for this content'
}),
('Content', {
'fields': ('content_html',)
'fields': ('content_html', 'word_count')
}),
('SEO', {
'fields': ('meta_title', 'meta_description', 'primary_keyword', 'secondary_keywords'),
'classes': ('collapse',)
}),
('WordPress Sync', {
'fields': ('external_id', 'external_url'),
@@ -112,6 +121,11 @@ class ContentAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
}),
)
def get_taxonomy_count(self, obj):
"""Display count of associated taxonomy terms"""
return obj.taxonomy_terms.count()
get_taxonomy_count.short_description = 'Taxonomy Count'
def get_site_display(self, obj):
"""Safely get site name"""
try: