This commit is contained in:
IGNY8 VPS (Salman)
2025-11-17 20:35:04 +00:00
parent b6b1aecdce
commit a7d432500f
3 changed files with 35 additions and 4 deletions

Binary file not shown.

View File

@@ -93,6 +93,8 @@ class Content(SiteSectorBaseModel):
task = models.OneToOneField(
Tasks,
on_delete=models.CASCADE,
null=True,
blank=True,
related_name='content_record',
help_text="The task this content belongs to"
)
@@ -172,10 +174,13 @@ class Content(SiteSectorBaseModel):
def save(self, *args, **kwargs):
"""Automatically set account, site, and sector from task"""
if self.task:
if self.task_id: # Check task_id instead of accessing task to avoid RelatedObjectDoesNotExist
try:
self.account = self.task.account
self.site = self.task.site
self.sector = self.task.sector
except self.task.RelatedObjectDoesNotExist:
pass # Task doesn't exist, skip
super().save(*args, **kwargs)
def __str__(self):

View File

@@ -0,0 +1,26 @@
# Generated migration to make Content.task nullable for Phase 4 synced content
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('writer', '0009_add_content_site_source_fields'),
]
operations = [
migrations.AlterField(
model_name='content',
name='task',
field=models.OneToOneField(
blank=True,
help_text='The task this content belongs to',
null=True,
on_delete=models.CASCADE,
related_name='content_record',
to='writer.tasks'
),
),
]