Add campaign UTM links and piha.li shortener as a core helper.

Keep mint/UTM in always-on core so email_sms and directmail stay optional, and brand utm_source from SITE_NAME (or UTM_SOURCE) instead of a hardcoded client name.
Closes westfarn/web_django_template#3
This commit is contained in:
2026-09-01 15:37:49 -05:00
parent 3a14bfb996
commit b62357c8be
25 changed files with 1344 additions and 16 deletions
+12
View File
@@ -23,6 +23,7 @@ from contacts.consent import ( # noqa: F401 — re-export for tests + providers
unsubscribe_all,
)
from contacts.models import Channel, Contact
from core.campaign_utm import ensure_campaign_utm_link
from core.scheduling import parse_scheduled_for
from email_sms.models import Campaign, Message, MessageTemplate
@@ -108,6 +109,17 @@ def create_campaign_draft(
created_by=created_by,
template=template,
)
if channel in (Channel.EMAIL, Channel.SMS):
body = ensure_campaign_utm_link(
body,
name=name,
medium=channel,
html=(channel == Channel.EMAIL),
campaign_id=campaign.pk,
)
if body != campaign.body_override:
campaign.body_override = body
campaign.save(update_fields=["body_override", "updated_at"])
contacts = list(opted_in_contacts(channel))
Message.objects.bulk_create(
[