feat(campaigns): timeline endpoint, admin-only manual activation, remove lead-set dates
This commit is contained in:
@@ -281,7 +281,6 @@ def create_campaign(
|
||||
tags: Optional[list[str]] = None,
|
||||
# Entry: scheduled_at
|
||||
scheduled_at: Optional[str] = None,
|
||||
start_date: Optional[str] = None,
|
||||
) -> dict:
|
||||
"""Create a new campaign. Does not commit; caller commits."""
|
||||
# Assign campaign = Campaign(
|
||||
@@ -302,7 +301,6 @@ def create_campaign(
|
||||
created_by=creator_id,
|
||||
# Keyword argument: scheduled_at
|
||||
scheduled_at=datetime.fromisoformat(scheduled_at) if scheduled_at else None,
|
||||
start_date=datetime.fromisoformat(start_date) if start_date else None,
|
||||
)
|
||||
# Stage new record(s) for database insertion
|
||||
db.add(campaign)
|
||||
@@ -459,8 +457,6 @@ def update_campaign(
|
||||
if "scheduled_at" in fields and fields["scheduled_at"]:
|
||||
# Assign fields["scheduled_at"] = datetime.fromisoformat(fields["scheduled_at"])
|
||||
fields["scheduled_at"] = datetime.fromisoformat(fields["scheduled_at"])
|
||||
if "start_date" in fields and fields["start_date"]:
|
||||
fields["start_date"] = datetime.fromisoformat(fields["start_date"])
|
||||
|
||||
# Iterate over fields.items()
|
||||
for field, value in fields.items():
|
||||
@@ -679,7 +675,7 @@ def activate_campaign(db: Session, campaign_id: str) -> Campaign:
|
||||
Does not commit; caller commits.
|
||||
"""
|
||||
# Assign campaign = db.query(Campaign).filter(Campaign.id == campaign_id).first()
|
||||
campaign = db.query(Campaign).filter(Campaign.id == campaign_id).first()
|
||||
campaign = db.query(Campaign).filter(Campaign.id == uuid.UUID(campaign_id)).first()
|
||||
# Check: not campaign
|
||||
if not campaign:
|
||||
# Raise EntityNotFoundError
|
||||
@@ -691,7 +687,7 @@ def activate_campaign(db: Session, campaign_id: str) -> Campaign:
|
||||
raise BusinessRuleViolation("Only draft campaigns can be activated")
|
||||
|
||||
# Assign test_count = db.query(CampaignTest).filter(CampaignTest.campaign_id == campaign_...
|
||||
test_count = db.query(CampaignTest).filter(CampaignTest.campaign_id == campaign_id).count()
|
||||
test_count = db.query(CampaignTest).filter(CampaignTest.campaign_id == campaign.id).count()
|
||||
# Check: test_count == 0
|
||||
if test_count == 0:
|
||||
# Raise BusinessRuleViolation
|
||||
|
||||
Reference in New Issue
Block a user