igny8-wp int
This commit is contained in:
@@ -58,6 +58,51 @@ def publish_content_to_wordpress(self, content_id: int, site_integration_id: int
|
||||
if len(content.content_html) > 150:
|
||||
excerpt += '...'
|
||||
|
||||
# Get taxonomy terms from ContentTaxonomyMap
|
||||
from igny8_core.business.content.models import ContentTaxonomyMap
|
||||
taxonomy_maps = ContentTaxonomyMap.objects.filter(content=content).select_related('taxonomy')
|
||||
|
||||
# Build categories and tags arrays from taxonomy mappings
|
||||
categories = []
|
||||
tags = []
|
||||
for mapping in taxonomy_maps:
|
||||
tax = mapping.taxonomy
|
||||
if tax:
|
||||
# Add taxonomy term name to categories (will be mapped in WordPress)
|
||||
categories.append(tax.name)
|
||||
|
||||
# Get images from Images model
|
||||
from igny8_core.modules.writer.models import Images
|
||||
featured_image_url = None
|
||||
gallery_images = []
|
||||
|
||||
images = Images.objects.filter(content=content).order_by('position')
|
||||
for image in images:
|
||||
if image.image_type == 'featured' and image.image_url:
|
||||
featured_image_url = image.image_url
|
||||
elif image.image_type == 'in_article' and image.image_url:
|
||||
gallery_images.append({
|
||||
'url': image.image_url,
|
||||
'alt': image.alt_text or '',
|
||||
'position': image.position
|
||||
})
|
||||
|
||||
# Add primary and secondary keywords as tags
|
||||
if content.primary_keyword:
|
||||
tags.append(content.primary_keyword)
|
||||
|
||||
if content.secondary_keywords:
|
||||
if isinstance(content.secondary_keywords, list):
|
||||
tags.extend(content.secondary_keywords)
|
||||
elif isinstance(content.secondary_keywords, str):
|
||||
import json
|
||||
try:
|
||||
keywords = json.loads(content.secondary_keywords)
|
||||
if isinstance(keywords, list):
|
||||
tags.extend(keywords)
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
pass
|
||||
|
||||
content_data = {
|
||||
'content_id': content.id,
|
||||
'task_id': task_id,
|
||||
@@ -75,15 +120,18 @@ def publish_content_to_wordpress(self, content_id: int, site_integration_id: int
|
||||
'seo_description': content.meta_description or '',
|
||||
'primary_keyword': content.primary_keyword or '',
|
||||
'secondary_keywords': content.secondary_keywords or [],
|
||||
# Content model has no featured_image field
|
||||
'featured_image_url': None,
|
||||
# Send featured image URL from Images model
|
||||
'featured_image_url': featured_image_url,
|
||||
'gallery_images': gallery_images,
|
||||
# Send cluster and sector IDs (Content has ForeignKey to cluster, not many-to-many)
|
||||
'cluster_id': content.cluster.id if content.cluster else None,
|
||||
'sector_id': content.sector.id if content.sector else None,
|
||||
# Content model has no direct sectors/clusters array or tags
|
||||
# Send categories and tags from taxonomy mappings and keywords
|
||||
'categories': categories,
|
||||
'tags': tags,
|
||||
# Keep for backward compatibility
|
||||
'sectors': [],
|
||||
'clusters': [],
|
||||
'tags': []
|
||||
'clusters': []
|
||||
}
|
||||
|
||||
# Call WordPress REST API
|
||||
|
||||
Reference in New Issue
Block a user