#!/usr/bin/env python3 """Patch the two main trucking source campaigns (MCS-150 #186, Inactive USDOT #188) coupon blocks to use the build step's on-the-fly computed prices (coupon_price_full / coupon_price_deal) instead of the hardcoded "$79 $47" / "$149 $89", which were only true at 40% off and would be false on the 20/30% A/B arms. Idempotent: re-running replaces the coupon if-block again with the same content. Run inside the workers container on prod: python3 scripts/patch_main_coupon_blocks.py [--dry-run] """ from __future__ import annotations import argparse import os import re import sys ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) if ROOT not in sys.path: sys.path.insert(0, ROOT) from scripts import build_trucking_campaigns as b # reuse lm_api + auth def _deal_block(service_phrase: str, extra_expiry_line: str = "") -> str: """Coupon-aware offer block matching the deficiency _deal_box structure: real was/now prices when priceable, percent-only otherwise.""" priced = ( '
' f'{service_phrase} for ' '' '{{ .Subscriber.Attribs.coupon_price_full }} ' '{{ .Subscriber.Attribs.coupon_price_deal }}.
' ) unpriced = ( '' f'{service_phrase}.
' ) expiry = "Expires {{ .Subscriber.Attribs.coupon_expires }}." if extra_expiry_line: expiry += " " + extra_expiry_line return ( '{{ if .Subscriber.Attribs.coupon_code }}\n' 'TODAY ONLY - {{ .Subscriber.Attribs.coupon_pct }}% OFF OUR SERVICE FEE
\n' '{{ if .Subscriber.Attribs.coupon_priceable }}' + priced + '{{ else }}' + unpriced + '{{ end }}\n' 'Use code ' '{{ .Subscriber.Attribs.coupon_code }} ' '(already applied when you click below).
\n' f'{expiry}
\n' '' 'We can file your MCS-150 update for you.
\n' 'No Login.gov needed. ' 'No government portals. We handle everything.
\n' '' 'Reactivation takes as few as 5 business days.
\n' 'We file electronically with ' 'FMCSA - no Login.gov account needed.
\n' '