Section 1 & 2 - #Migration Run
This commit is contained in:
@@ -1472,13 +1472,13 @@ class AutomationService:
|
||||
time.sleep(delay)
|
||||
|
||||
def run_stage_7(self):
|
||||
"""Stage 7: Auto-Approve and Publish Review Content
|
||||
"""Stage 7: Auto-Approve Review Content
|
||||
|
||||
This stage automatically approves content in 'review' status and
|
||||
marks it as 'published' (or queues for WordPress sync).
|
||||
marks it as 'approved' (ready for publishing to WordPress).
|
||||
"""
|
||||
stage_number = 7
|
||||
stage_name = "Review → Published"
|
||||
stage_name = "Review → Approved"
|
||||
start_time = time.time()
|
||||
|
||||
# Query content ready for review
|
||||
@@ -1538,7 +1538,7 @@ class AutomationService:
|
||||
'review_total': total_count,
|
||||
'approved_count': approved_count,
|
||||
'content_ids': list(Content.objects.filter(
|
||||
site=self.site, status='published', updated_at__gte=self.run.started_at
|
||||
site=self.site, status='approved', updated_at__gte=self.run.started_at
|
||||
).values_list('id', flat=True)),
|
||||
'partial': True,
|
||||
'stopped_reason': reason,
|
||||
@@ -1553,8 +1553,8 @@ class AutomationService:
|
||||
stage_number, f"Approving content {idx}/{total_count}: {content.title}"
|
||||
)
|
||||
|
||||
# Approve content by changing status to 'published'
|
||||
content.status = 'published'
|
||||
# Approve content by changing status to 'approved' (ready for publishing)
|
||||
content.status = 'approved'
|
||||
content.save(update_fields=['status', 'updated_at'])
|
||||
|
||||
approved_count += 1
|
||||
@@ -1593,7 +1593,7 @@ class AutomationService:
|
||||
time_elapsed = self._format_time_elapsed(start_time)
|
||||
content_ids = list(Content.objects.filter(
|
||||
site=self.site,
|
||||
status='published',
|
||||
status='approved',
|
||||
updated_at__gte=self.run.started_at
|
||||
).values_list('id', flat=True))
|
||||
|
||||
@@ -1617,7 +1617,7 @@ class AutomationService:
|
||||
# Release lock
|
||||
cache.delete(f'automation_lock_{self.site.id}')
|
||||
|
||||
logger.info(f"[AutomationService] Stage 7 complete: {approved_count} content pieces approved and published")
|
||||
logger.info(f"[AutomationService] Stage 7 complete: {approved_count} content pieces approved (ready for publishing)")
|
||||
|
||||
def pause_automation(self):
|
||||
"""Pause current automation run"""
|
||||
|
||||
@@ -271,7 +271,8 @@ class Content(SoftDeletableModel, SiteSectorBaseModel):
|
||||
STATUS_CHOICES = [
|
||||
('draft', 'Draft'),
|
||||
('review', 'Review'),
|
||||
('published', 'Published'),
|
||||
('approved', 'Approved'), # Ready for publishing to external site
|
||||
('published', 'Published'), # Actually published on external site
|
||||
]
|
||||
status = models.CharField(
|
||||
max_length=50,
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# Generated by Django 5.2.9 on 2026-01-01 06:13
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('writer', '0013_add_caption_to_images'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ImagePrompts',
|
||||
fields=[
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Image Prompt',
|
||||
'verbose_name_plural': 'Image Prompts',
|
||||
'proxy': True,
|
||||
'indexes': [],
|
||||
'constraints': [],
|
||||
},
|
||||
bases=('writer.images',),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='content',
|
||||
name='status',
|
||||
field=models.CharField(choices=[('draft', 'Draft'), ('review', 'Review'), ('approved', 'Approved'), ('published', 'Published')], db_index=True, default='draft', help_text='Content status', max_length=50),
|
||||
),
|
||||
]
|
||||
@@ -11,8 +11,8 @@ class TasksSerializer(serializers.ModelSerializer):
|
||||
"""Serializer for Tasks model - Stage 1 refactored"""
|
||||
cluster_name = serializers.SerializerMethodField()
|
||||
sector_name = serializers.SerializerMethodField()
|
||||
site_id = serializers.IntegerField(write_only=True, required=False)
|
||||
sector_id = serializers.IntegerField(write_only=True, required=False)
|
||||
site_id = serializers.IntegerField(read_only=True)
|
||||
sector_id = serializers.IntegerField(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Tasks
|
||||
@@ -162,8 +162,8 @@ class ContentSerializer(serializers.ModelSerializer):
|
||||
has_image_prompts = serializers.SerializerMethodField()
|
||||
image_status = serializers.SerializerMethodField()
|
||||
has_generated_images = serializers.SerializerMethodField()
|
||||
site_id = serializers.IntegerField(write_only=True, required=False)
|
||||
sector_id = serializers.IntegerField(write_only=True, required=False)
|
||||
site_id = serializers.IntegerField(read_only=True)
|
||||
sector_id = serializers.IntegerField(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Content
|
||||
@@ -300,8 +300,8 @@ class ContentSerializer(serializers.ModelSerializer):
|
||||
class ContentTaxonomySerializer(serializers.ModelSerializer):
|
||||
"""Serializer for ContentTaxonomy model - Stage 1 refactored"""
|
||||
content_count = serializers.SerializerMethodField()
|
||||
site_id = serializers.IntegerField(write_only=True, required=False)
|
||||
sector_id = serializers.IntegerField(write_only=True, required=False)
|
||||
site_id = serializers.IntegerField(read_only=True)
|
||||
sector_id = serializers.IntegerField(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = ContentTaxonomy
|
||||
|
||||
@@ -751,6 +751,19 @@ class ContentViewSet(SiteSectorModelViewSet):
|
||||
'source',
|
||||
]
|
||||
|
||||
def get_queryset(self):
|
||||
"""Override to support status__in filtering for multiple statuses"""
|
||||
queryset = super().get_queryset()
|
||||
|
||||
# Support status__in query param (comma-separated list of statuses)
|
||||
status_in = self.request.query_params.get('status__in', None)
|
||||
if status_in:
|
||||
statuses = [s.strip() for s in status_in.split(',') if s.strip()]
|
||||
if statuses:
|
||||
queryset = queryset.filter(status__in=statuses)
|
||||
|
||||
return queryset
|
||||
|
||||
def perform_create(self, serializer):
|
||||
"""Override to check monthly word limit and set account"""
|
||||
user = getattr(self.request, 'user', None)
|
||||
|
||||
Reference in New Issue
Block a user