- Added Linker and Optimizer apps to `INSTALLED_APPS` in `settings.py`. - Configured API endpoints for Linker and Optimizer in `urls.py`. - Implemented `OptimizeContentFunction` for content optimization in the AI module. - Created prompts for content optimization and site structure generation. - Updated `OptimizerService` to utilize the new AI function for content optimization. - Developed frontend components including dashboards and content lists for Linker and Optimizer. - Integrated new routes and sidebar navigation for Linker and Optimizer in the frontend. - Enhanced content management with source and sync status filters in the Writer module. - Comprehensive test coverage added for new features and components.
43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
from rest_framework import serializers
|
|
from igny8_core.business.content.models import Content
|
|
|
|
|
|
class LinkContentSerializer(serializers.Serializer):
|
|
"""Serializer for linking content"""
|
|
content_id = serializers.IntegerField(required=True)
|
|
|
|
def validate_content_id(self, value):
|
|
try:
|
|
content = Content.objects.get(id=value)
|
|
account = self.context['request'].user.account if hasattr(self.context['request'].user, 'account') else None
|
|
if account and content.account != account:
|
|
raise serializers.ValidationError("Content not found or access denied")
|
|
return value
|
|
except Content.DoesNotExist:
|
|
raise serializers.ValidationError("Content not found")
|
|
|
|
|
|
class BatchLinkContentSerializer(serializers.Serializer):
|
|
"""Serializer for batch linking"""
|
|
content_ids = serializers.ListField(
|
|
child=serializers.IntegerField(),
|
|
min_length=1,
|
|
max_length=50
|
|
)
|
|
|
|
def validate_content_ids(self, value):
|
|
account = self.context['request'].user.account if hasattr(self.context['request'].user, 'account') else None
|
|
if not account:
|
|
raise serializers.ValidationError("Account not found")
|
|
|
|
content_ids = Content.objects.filter(
|
|
id__in=value,
|
|
account=account
|
|
).values_list('id', flat=True)
|
|
|
|
if len(content_ids) != len(value):
|
|
raise serializers.ValidationError("Some content IDs are invalid or inaccessible")
|
|
|
|
return list(content_ids)
|
|
|