AI AUtomtaion, Schudelign and publishign fromt and backe end refoactr
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
# Generated by Django 5.2.10 on 2026-01-17 14:37
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('integration', '0003_add_publishing_settings'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='publishingsettings',
|
||||
name='queue_limit',
|
||||
field=models.PositiveIntegerField(default=100, help_text='DEPRECATED - not used'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='publishingsettings',
|
||||
name='scheduling_mode',
|
||||
field=models.CharField(default='time_slots', help_text='DEPRECATED - always uses time_slots mode', max_length=20),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='publishingsettings',
|
||||
name='stagger_end_time',
|
||||
field=models.TimeField(default='18:00', help_text='DEPRECATED - not used'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='publishingsettings',
|
||||
name='stagger_interval_minutes',
|
||||
field=models.PositiveIntegerField(default=30, help_text='DEPRECATED - not used'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='publishingsettings',
|
||||
name='stagger_start_time',
|
||||
field=models.TimeField(default='09:00', help_text='DEPRECATED - not used'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='publishingsettings',
|
||||
name='daily_publish_limit',
|
||||
field=models.PositiveIntegerField(default=3, help_text='DEPRECATED - derived from time_slots'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='publishingsettings',
|
||||
name='monthly_publish_limit',
|
||||
field=models.PositiveIntegerField(default=50, help_text='DEPRECATED - not used'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='publishingsettings',
|
||||
name='weekly_publish_limit',
|
||||
field=models.PositiveIntegerField(default=15, help_text='DEPRECATED - derived from days × slots'),
|
||||
),
|
||||
]
|
||||
@@ -247,8 +247,16 @@ class SyncEvent(AccountBaseModel):
|
||||
|
||||
class PublishingSettings(AccountBaseModel):
|
||||
"""
|
||||
Site-level publishing configuration settings.
|
||||
Controls automatic approval, publishing limits, and scheduling.
|
||||
Site-level publishing SCHEDULE configuration (SIMPLIFIED).
|
||||
Controls automatic approval, publishing, and time-slot based scheduling.
|
||||
|
||||
REMOVED (per settings consolidation plan):
|
||||
- scheduling_mode (only time_slots needed)
|
||||
- daily_publish_limit (derived: len(time_slots))
|
||||
- weekly_publish_limit (derived: len(time_slots) × len(publish_days))
|
||||
- monthly_publish_limit (not needed)
|
||||
- stagger_* fields (not needed)
|
||||
- queue_limit (not needed)
|
||||
"""
|
||||
|
||||
DEFAULT_PUBLISH_DAYS = ['mon', 'tue', 'wed', 'thu', 'fri']
|
||||
@@ -273,26 +281,7 @@ class PublishingSettings(AccountBaseModel):
|
||||
help_text="Automatically publish approved content to the external site"
|
||||
)
|
||||
|
||||
# Publishing limits
|
||||
daily_publish_limit = models.PositiveIntegerField(
|
||||
default=3,
|
||||
validators=[MinValueValidator(1)],
|
||||
help_text="Maximum number of articles to publish per day"
|
||||
)
|
||||
|
||||
weekly_publish_limit = models.PositiveIntegerField(
|
||||
default=15,
|
||||
validators=[MinValueValidator(1)],
|
||||
help_text="Maximum number of articles to publish per week"
|
||||
)
|
||||
|
||||
monthly_publish_limit = models.PositiveIntegerField(
|
||||
default=50,
|
||||
validators=[MinValueValidator(1)],
|
||||
help_text="Maximum number of articles to publish per month"
|
||||
)
|
||||
|
||||
# Publishing schedule
|
||||
# Publishing schedule - Days + Time Slots only (SIMPLIFIED)
|
||||
publish_days = models.JSONField(
|
||||
default=list,
|
||||
help_text="Days of the week to publish (mon, tue, wed, thu, fri, sat, sun)"
|
||||
@@ -303,6 +292,21 @@ class PublishingSettings(AccountBaseModel):
|
||||
help_text="Times of day to publish (HH:MM format, e.g., ['09:00', '14:00', '18:00'])"
|
||||
)
|
||||
|
||||
# DEPRECATED FIELDS - kept for backwards compatibility during migration
|
||||
# These will be removed in a future migration
|
||||
scheduling_mode = models.CharField(
|
||||
max_length=20,
|
||||
default='time_slots',
|
||||
help_text="DEPRECATED - always uses time_slots mode"
|
||||
)
|
||||
daily_publish_limit = models.PositiveIntegerField(default=3, help_text="DEPRECATED - derived from time_slots")
|
||||
weekly_publish_limit = models.PositiveIntegerField(default=15, help_text="DEPRECATED - derived from days × slots")
|
||||
monthly_publish_limit = models.PositiveIntegerField(default=50, help_text="DEPRECATED - not used")
|
||||
stagger_start_time = models.TimeField(default='09:00', help_text="DEPRECATED - not used")
|
||||
stagger_end_time = models.TimeField(default='18:00', help_text="DEPRECATED - not used")
|
||||
stagger_interval_minutes = models.PositiveIntegerField(default=30, help_text="DEPRECATED - not used")
|
||||
queue_limit = models.PositiveIntegerField(default=100, help_text="DEPRECATED - not used")
|
||||
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
@@ -323,6 +327,22 @@ class PublishingSettings(AccountBaseModel):
|
||||
self.publish_time_slots = self.DEFAULT_TIME_SLOTS
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
# Calculated capacity properties (read-only, derived from days × slots)
|
||||
@property
|
||||
def daily_capacity(self) -> int:
|
||||
"""Daily publishing capacity = number of time slots"""
|
||||
return len(self.publish_time_slots) if self.publish_time_slots else 0
|
||||
|
||||
@property
|
||||
def weekly_capacity(self) -> int:
|
||||
"""Weekly publishing capacity = time slots × publish days"""
|
||||
return self.daily_capacity * len(self.publish_days) if self.publish_days else 0
|
||||
|
||||
@property
|
||||
def monthly_capacity(self) -> int:
|
||||
"""Monthly publishing capacity (approximate: weekly × 4.3)"""
|
||||
return int(self.weekly_capacity * 4.3)
|
||||
|
||||
@classmethod
|
||||
def get_or_create_for_site(cls, site):
|
||||
"""Get or create publishing settings for a site with defaults"""
|
||||
@@ -332,9 +352,6 @@ class PublishingSettings(AccountBaseModel):
|
||||
'account': site.account,
|
||||
'auto_approval_enabled': True,
|
||||
'auto_publish_enabled': True,
|
||||
'daily_publish_limit': 3,
|
||||
'weekly_publish_limit': 15,
|
||||
'monthly_publish_limit': 50,
|
||||
'publish_days': cls.DEFAULT_PUBLISH_DAYS,
|
||||
'publish_time_slots': cls.DEFAULT_TIME_SLOTS,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user