support versions, campaign structure change

This commit is contained in:
2026-06-11 02:54:39 +02:00
parent 3b06f3670e
commit b67c8abdc5
7 changed files with 318 additions and 40 deletions

View File

@@ -130,6 +130,22 @@ QUEUEABLE_VALIDATION_STATUSES = {
}
def _version_is_user_locked(version: CampaignVersion) -> bool:
return bool(version.published_at)
def _version_is_validated_and_locked(version: CampaignVersion) -> bool:
validation = version.validation_summary if isinstance(version.validation_summary, dict) else {}
return bool(version.locked_at and validation.get("ok") is True and not _version_is_user_locked(version))
def _ensure_version_validated_and_locked(version: CampaignVersion) -> None:
if _version_is_user_locked(version):
raise QueueingError("User-locked audit-safe versions cannot be queued, dry-run or sent. Create an editable copy instead.")
if not _version_is_validated_and_locked(version):
raise QueueingError("Campaign version must be validated and locked before building, queueing, dry-run or sending.")
def _utcnow() -> datetime:
return datetime.now(timezone.utc)
@@ -182,6 +198,7 @@ def queue_campaign_jobs(
campaign = _get_campaign_for_tenant(session, campaign_id=campaign_id, tenant_id=tenant_id)
version = _get_current_version(session, campaign, version_id=version_id)
_ensure_version_validated_and_locked(version)
allowed_validation = {JobValidationStatus.READY.value}
if include_warnings: