Section 3-8 - #MIgration Runs -
Multiple Migfeat: Update publishing terminology and add publishing settings - Changed references from "WordPress" to "Site" across multiple components for consistency. - Introduced a new "Publishing" tab in Site Settings to manage automatic content approval and publishing behavior. - Added publishing settings model to the backend with fields for auto-approval, auto-publish, and publishing limits. - Implemented Celery tasks for scheduling and processing automated content publishing. - Enhanced Writer Dashboard to include metrics for content published to the site and scheduled for publishing.
This commit is contained in:
@@ -244,3 +244,100 @@ class SyncEvent(AccountBaseModel):
|
||||
def __str__(self):
|
||||
return f"{self.get_event_type_display()} - {self.description[:50]}"
|
||||
|
||||
|
||||
class PublishingSettings(AccountBaseModel):
|
||||
"""
|
||||
Site-level publishing configuration settings.
|
||||
Controls automatic approval, publishing limits, and scheduling.
|
||||
"""
|
||||
|
||||
DEFAULT_PUBLISH_DAYS = ['mon', 'tue', 'wed', 'thu', 'fri']
|
||||
DEFAULT_TIME_SLOTS = ['09:00', '14:00', '18:00']
|
||||
|
||||
site = models.OneToOneField(
|
||||
'igny8_core_auth.Site',
|
||||
on_delete=models.CASCADE,
|
||||
related_name='publishing_settings',
|
||||
help_text="Site these publishing settings belong to"
|
||||
)
|
||||
|
||||
# Auto-approval settings
|
||||
auto_approval_enabled = models.BooleanField(
|
||||
default=True,
|
||||
help_text="Automatically approve content after review (moves to 'approved' status)"
|
||||
)
|
||||
|
||||
# Auto-publish settings
|
||||
auto_publish_enabled = models.BooleanField(
|
||||
default=True,
|
||||
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
|
||||
publish_days = models.JSONField(
|
||||
default=list,
|
||||
help_text="Days of the week to publish (mon, tue, wed, thu, fri, sat, sun)"
|
||||
)
|
||||
|
||||
publish_time_slots = models.JSONField(
|
||||
default=list,
|
||||
help_text="Times of day to publish (HH:MM format, e.g., ['09:00', '14:00', '18:00'])"
|
||||
)
|
||||
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
app_label = 'integration'
|
||||
db_table = 'igny8_publishing_settings'
|
||||
verbose_name = 'Publishing Settings'
|
||||
verbose_name_plural = 'Publishing Settings'
|
||||
|
||||
def __str__(self):
|
||||
return f"Publishing Settings for {self.site.name}"
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
"""Set defaults for JSON fields if empty"""
|
||||
if not self.publish_days:
|
||||
self.publish_days = self.DEFAULT_PUBLISH_DAYS
|
||||
if not self.publish_time_slots:
|
||||
self.publish_time_slots = self.DEFAULT_TIME_SLOTS
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def get_or_create_for_site(cls, site):
|
||||
"""Get or create publishing settings for a site with defaults"""
|
||||
settings, created = cls.objects.get_or_create(
|
||||
site=site,
|
||||
defaults={
|
||||
'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,
|
||||
}
|
||||
)
|
||||
return settings, created
|
||||
|
||||
|
||||
Reference in New Issue
Block a user