Files
igny8/backend/igny8_core/modules/planner/admin.py
IGNY8 VPS (Salman) 55dfd5ad19 Enhance Content Management with New Taxonomy and Attribute Models
- Introduced `ContentTaxonomy` and `ContentAttribute` models for improved content categorization and attribute management.
- Updated `Content` model to support new fields for content format, cluster role, and external type.
- Refactored serializers and views to accommodate new models, including `ContentTaxonomySerializer` and `ContentAttributeSerializer`.
- Added new API endpoints for managing taxonomies and attributes, enhancing the content management capabilities.
- Updated admin interfaces for `Content`, `ContentTaxonomy`, and `ContentAttribute` to reflect new structures and improve usability.
- Implemented backward compatibility for existing attribute mappings.
- Enhanced filtering and search capabilities in the API for better content retrieval.
2025-11-22 00:21:00 +00:00

119 lines
4.1 KiB
Python

from django.contrib import admin
from igny8_core.admin.base import SiteSectorAdminMixin
from .models import Keywords, Clusters, ContentIdeas
@admin.register(Clusters)
class ClustersAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
list_display = ['name', 'site', 'sector', 'keywords_count', 'volume', 'status', 'created_at']
list_filter = ['status', 'site', 'sector']
search_fields = ['name']
ordering = ['name']
def get_site_display(self, obj):
"""Safely get site name"""
try:
return obj.site.name if obj.site else '-'
except:
return '-'
get_site_display.short_description = 'Site'
def get_sector_display(self, obj):
"""Safely get sector name"""
try:
return obj.sector.name if obj.sector else '-'
except:
return '-'
@admin.register(Keywords)
class KeywordsAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
list_display = ['keyword', 'seed_keyword', 'site', 'sector', 'cluster', 'volume', 'difficulty', 'intent', 'status', 'created_at']
list_filter = ['status', 'seed_keyword__intent', 'site', 'sector', 'seed_keyword__industry', 'seed_keyword__sector']
search_fields = ['seed_keyword__keyword']
ordering = ['-created_at']
def get_site_display(self, obj):
"""Safely get site name"""
try:
return obj.site.name if obj.site else '-'
except:
return '-'
get_site_display.short_description = 'Site'
def get_sector_display(self, obj):
"""Safely get sector name"""
try:
return obj.sector.name if obj.sector else '-'
except:
return '-'
def get_cluster_display(self, obj):
"""Safely get cluster name"""
try:
return obj.cluster.name if obj.cluster else '-'
except:
return '-'
get_cluster_display.short_description = 'Cluster'
@admin.register(ContentIdeas)
class ContentIdeasAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
list_display = ['idea_title', 'site', 'sector', 'description_preview', 'site_entity_type', 'cluster_role', 'status', 'keyword_cluster', 'estimated_word_count', 'created_at']
list_filter = ['status', 'site_entity_type', 'cluster_role', 'site', 'sector']
search_fields = ['idea_title', 'target_keywords', 'description']
ordering = ['-created_at']
readonly_fields = ['content_structure', 'content_type']
fieldsets = (
('Basic Info', {
'fields': ('idea_title', 'description', 'status', 'site', 'sector')
}),
('Content Planning', {
'fields': ('site_entity_type', 'cluster_role', 'estimated_word_count')
}),
('Keywords & Clustering', {
'fields': ('keyword_cluster', 'target_keywords', 'taxonomy')
}),
('Deprecated Fields (Read-Only)', {
'fields': ('content_structure', 'content_type'),
'classes': ('collapse',),
'description': 'These fields are deprecated. Use site_entity_type and cluster_role instead.'
}),
)
def description_preview(self, obj):
"""Show a truncated preview of the description"""
if not obj.description:
return '-'
# Truncate to 100 characters
preview = obj.description[:100]
if len(obj.description) > 100:
preview += '...'
return preview
description_preview.short_description = 'Description'
def get_site_display(self, obj):
"""Safely get site name"""
try:
return obj.site.name if obj.site else '-'
except:
return '-'
get_site_display.short_description = 'Site'
def get_sector_display(self, obj):
"""Safely get sector name"""
try:
return obj.sector.name if obj.sector else '-'
except:
return '-'
def get_keyword_cluster_display(self, obj):
"""Safely get cluster name"""
try:
return obj.keyword_cluster.name if obj.keyword_cluster else '-'
except:
return '-'
get_keyword_cluster_display.short_description = 'Cluster'