Refactor error_response function for improved argument handling

- Enhanced the `error_response` function to support backward compatibility by normalizing arguments when positional arguments are misused.
- Updated various views to pass `None` for the `errors` parameter in `error_response` calls, ensuring consistent response formatting.
- Adjusted logging in `ContentSyncService` and `WordPressClient` to use debug level for expected 401 errors, improving log clarity.
- Removed deprecated fields from serializers and views, streamlining content management processes.
This commit is contained in:
IGNY8 VPS (Salman)
2025-11-22 03:04:35 +00:00
parent c84bb9bc14
commit 84c18848b0
10 changed files with 424 additions and 51 deletions

View File

@@ -25,8 +25,7 @@ class TasksSerializer(serializers.ModelSerializer):
content_html = serializers.SerializerMethodField()
content_primary_keyword = serializers.SerializerMethodField()
content_secondary_keywords = serializers.SerializerMethodField()
content_tags = serializers.SerializerMethodField()
content_categories = serializers.SerializerMethodField()
# tags/categories removed — use taxonomies M2M on Content
class Meta:
model = Tasks
@@ -40,25 +39,16 @@ class TasksSerializer(serializers.ModelSerializer):
'sector_name',
'idea_id',
'idea_title',
'content_structure',
'content_type',
'status',
'content',
'word_count',
'meta_title',
'meta_description',
# task-level raw content/seo fields removed — stored on Content
'content_html',
'content_primary_keyword',
'content_secondary_keywords',
'content_tags',
'content_categories',
'assigned_post_id',
'post_url',
'created_at',
'updated_at',
'site_id',
'sector_id',
'account_id',
'created_at',
'updated_at',
]
read_only_fields = ['id', 'created_at', 'updated_at', 'account_id']
@@ -120,12 +110,18 @@ class TasksSerializer(serializers.ModelSerializer):
return record.secondary_keywords if record else []
def get_content_tags(self, obj):
# tags removed; derive taxonomies from Content.taxonomies if needed
record = self._get_content_record(obj)
return record.tags if record else []
if not record:
return []
return [t.name for t in record.taxonomies.all()]
def get_content_categories(self, obj):
# categories removed; derive hierarchical taxonomies from Content.taxonomies
record = self._get_content_record(obj)
return record.categories if record else []
if not record:
return []
return [t.name for t in record.taxonomies.filter(taxonomy_type__in=['category','product_cat'])]
def _cluster_map_qs(self, obj):
return ContentClusterMap.objects.filter(task=obj).select_related('cluster')
@@ -269,8 +265,6 @@ class ContentSerializer(serializers.ModelSerializer):
'meta_description',
'primary_keyword',
'secondary_keywords',
'tags',
'categories',
'status',
'generated_at',
'updated_at',