fix: repair RU capabilities CTA note

This commit is contained in:
2026-05-03 03:37:14 +02:00
parent e04b5dd8b4
commit 210f90b899
2 changed files with 80 additions and 59 deletions

2
Jenkinsfile vendored
View File

@@ -186,7 +186,7 @@ PY
steps { steps {
sh ''' sh '''
set -e set -e
REMOTE_CMD="cd '${STAGING_AUDIT_PROJECT_DIR}' && '${STAGING_AUDIT_MANAGE}' fix_no_credit_card_text --apply" REMOTE_CMD="cd '${STAGING_AUDIT_PROJECT_DIR}' && '${STAGING_AUDIT_MANAGE}' fix_no_credit_card_text --apply --page-id 675"
sudo -n -u mandel -g www-data /srv/apps/mandel-dashboard/.venv/bin/python /srv/apps/mandel-dashboard/bin/deploy_stg_from_jenkins.py "${STAGING_AUDIT_PROJECT_NAME}" --command "$REMOTE_CMD" sudo -n -u mandel -g www-data /srv/apps/mandel-dashboard/.venv/bin/python /srv/apps/mandel-dashboard/bin/deploy_stg_from_jenkins.py "${STAGING_AUDIT_PROJECT_NAME}" --command "$REMOTE_CMD"
''' '''
} }

View File

@@ -80,6 +80,11 @@ class Command(BaseCommand):
) )
def add_arguments(self, parser): def add_arguments(self, parser):
parser.add_argument(
"--page-id",
type=int,
help="Optional Wagtail page id to fix (overrides capabilities lookup).",
)
parser.add_argument( parser.add_argument(
"--apply", "--apply",
action="store_true", action="store_true",
@@ -88,8 +93,15 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
apply_changes = options["apply"] apply_changes = options["apply"]
page_id = options.get("page_id")
# The live issue was observed on RU "Capabilities" (mogelijkheden) translation. with transaction.atomic():
if page_id:
page = Page.objects.filter(id=page_id).specific().first()
if page is None:
raise CommandError(f"Page id={page_id} not found")
self._fix_page(page, apply_changes=apply_changes)
else:
nl_locale = Locale.objects.filter(language_code="nl").first() nl_locale = Locale.objects.filter(language_code="nl").first()
if nl_locale is None: if nl_locale is None:
raise CommandError("Locale nl not found") raise CommandError("Locale nl not found")
@@ -100,9 +112,10 @@ class Command(BaseCommand):
.first() .first()
) )
if source is None: if source is None:
raise CommandError("Could not find source page nl/slug=mogelijkheden") raise CommandError(
"Could not find source page nl/slug=mogelijkheden"
)
with transaction.atomic():
for locale in Locale.objects.all().order_by("language_code"): for locale in Locale.objects.all().order_by("language_code"):
code = locale.language_code code = locale.language_code
page = ( page = (
@@ -113,13 +126,25 @@ class Command(BaseCommand):
.first() .first()
) )
if page is None: if page is None:
self.stdout.write(f"SKIP {code}: no translation for mogelijkheden") self.stdout.write(
f"SKIP {code}: no translation for mogelijkheden"
)
continue continue
self._fix_page(page, apply_changes=apply_changes)
if not apply_changes:
raise CommandError(
"Dry-run complete. Re-run with --apply to persist changes."
)
def _fix_page(self, page: Page, *, apply_changes: bool) -> None:
locale = page.locale
code = locale.language_code
specific = page.specific specific = page.specific
if not hasattr(specific, "body"): if not hasattr(specific, "body"):
self.stdout.write(f"SKIP {code}: no body streamfield") self.stdout.write(f"SKIP {code}: no body streamfield")
continue return
body = specific.body body = specific.body
raw_data = list(body.raw_data) raw_data = list(body.raw_data)
@@ -127,6 +152,7 @@ class Command(BaseCommand):
contact_url = _localized_url(131, locale) # contact contact_url = _localized_url(131, locale) # contact
services_url = _localized_url(129, locale) # services services_url = _localized_url(129, locale) # services
changed = False changed = False
for block in raw_data: for block in raw_data:
if block.get("type") != "saas_cta_footer": if block.get("type") != "saas_cta_footer":
continue continue
@@ -144,7 +170,7 @@ class Command(BaseCommand):
if not changed: if not changed:
self.stdout.write(f"OK {code}: no cta footer changes needed") self.stdout.write(f"OK {code}: no cta footer changes needed")
continue return
self.stdout.write( self.stdout.write(
f"CHG {code}: fixed saas_cta_footer no_credit_card_text/urls" f"CHG {code}: fixed saas_cta_footer no_credit_card_text/urls"
@@ -153,8 +179,3 @@ class Command(BaseCommand):
if apply_changes: if apply_changes:
rev = specific.save_revision() rev = specific.save_revision()
rev.publish() rev.publish()
if not apply_changes:
raise CommandError(
"Dry-run complete. Re-run with --apply to persist changes."
)