Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fixes #233

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nmhs_cms/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
# RECAPTCHA Settings
RECAPTCHA_PUBLIC_KEY = env.str('RECAPTCHA_PUBLIC_KEY', '')
RECAPTCHA_PRIVATE_KEY = env.str('RECAPTCHA_PRIVATE_KEY', '')
RECAPTCHA_DOMAIN = env.str('RECAPTCHA_DOMAIN', 'www.google.com')
# RECAPTCHA_DOMAIN = env.str('RECAPTCHA_DOMAIN', 'www.google.com')
RECAPTCHA_VERIFY_REQUEST_TIMEOUT = env.str('RECAPTCHA_VERIFY_REQUEST_TIMEOUT', "60")

# try to convert RECAPTCHA_VERIFY_REQUEST_TIMEOUT to an integer
Expand Down
45 changes: 44 additions & 1 deletion pages/cap/migrations/0016_auto_20240530_1637.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,48 @@
# Generated by Django 4.2.7 on 2024-05-30 13:37

from django.db import migrations
from wagtail.blocks import StreamValue

from pages.cap.models import CapAlertPage


def change_boundary_blocks_to_polygon(apps, schema_editor):
alerts = CapAlertPage.objects.all()

for cap_alert_page in alerts:
alert_infos = cap_alert_page.info

info_blocks = []
should_save = False

for info in alert_infos:
rep = info.block.get_api_representation(info.value)
areas = rep.get("area")

for area in areas:
if area["type"] == "boundary_block":
area["type"] = "polygon_block"
area["value"]["polygon"] = area["value"]["boundary"]
should_save = True

rep["area"] = areas

stream_item = {
"type": "alert_info",
"value": rep
}

info_blocks.append(stream_item)

if should_save:
print(f"Converting '{cap_alert_page.title}' boundaries to polygon blocks")
cap_alert_page.info = StreamValue(cap_alert_page.info.stream_block, info_blocks, is_lazy=True)
cap_alert_page.save()


def backwards(apps, schema_editor):
"""nothing to do"""
pass


class Migration(migrations.Migration):
Expand All @@ -13,5 +55,6 @@ class Migration(migrations.Migration):
model_name='capalertpage',
old_name='identifier',
new_name='guid'
)
),
migrations.RunPython(change_boundary_blocks_to_polygon, backwards),
]