taxonomy fix
This commit is contained in:
@@ -242,24 +242,24 @@ class GenerateContentFunction(BaseAIFunction):
|
||||
tag_name = tag_name.strip()
|
||||
if tag_name:
|
||||
try:
|
||||
# Get or create tag taxonomy term
|
||||
tag_slug = slugify(tag_name)
|
||||
# Get or create tag taxonomy term using site + slug + type for uniqueness
|
||||
tag_obj, created = ContentTaxonomy.objects.get_or_create(
|
||||
site=task.site,
|
||||
name=tag_name,
|
||||
slug=tag_slug,
|
||||
taxonomy_type='tag',
|
||||
defaults={
|
||||
'slug': slugify(tag_name),
|
||||
'name': tag_name,
|
||||
'sector': task.sector,
|
||||
'account': task.account,
|
||||
'description': '', # Required by database
|
||||
'external_taxonomy': '', # Required by database
|
||||
'sync_status': '', # Required by database
|
||||
'count': 0, # Required by database
|
||||
'metadata': {}, # Required by database
|
||||
'description': '',
|
||||
'external_taxonomy': '',
|
||||
'count': 0,
|
||||
'metadata': {},
|
||||
}
|
||||
)
|
||||
content_record.taxonomy_terms.add(tag_obj)
|
||||
logger.info(f"{'Created' if created else 'Found'} and linked tag: {tag_name} (ID: {tag_obj.id})")
|
||||
logger.info(f"{'Created' if created else 'Found'} and linked tag: {tag_name} (ID: {tag_obj.id}, Slug: {tag_slug})")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to add tag '{tag_name}': {e}", exc_info=True)
|
||||
|
||||
@@ -271,24 +271,24 @@ class GenerateContentFunction(BaseAIFunction):
|
||||
category_name = category_name.strip()
|
||||
if category_name:
|
||||
try:
|
||||
# Get or create category taxonomy term
|
||||
category_slug = slugify(category_name)
|
||||
# Get or create category taxonomy term using site + slug + type for uniqueness
|
||||
category_obj, created = ContentTaxonomy.objects.get_or_create(
|
||||
site=task.site,
|
||||
name=category_name,
|
||||
slug=category_slug,
|
||||
taxonomy_type='category',
|
||||
defaults={
|
||||
'slug': slugify(category_name),
|
||||
'name': category_name,
|
||||
'sector': task.sector,
|
||||
'account': task.account,
|
||||
'description': '', # Required by database
|
||||
'external_taxonomy': '', # Required by database
|
||||
'sync_status': '', # Required by database
|
||||
'count': 0, # Required by database
|
||||
'metadata': {}, # Required by database
|
||||
'description': '',
|
||||
'external_taxonomy': '',
|
||||
'count': 0,
|
||||
'metadata': {},
|
||||
}
|
||||
)
|
||||
content_record.taxonomy_terms.add(category_obj)
|
||||
logger.info(f"{'Created' if created else 'Found'} and linked category: {category_name} (ID: {category_obj.id})")
|
||||
logger.info(f"{'Created' if created else 'Found'} and linked category: {category_name} (ID: {category_obj.id}, Slug: {category_slug})")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to add category '{category_name}': {e}", exc_info=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user