diff --git a/src/openforms/config/migrations/0055_v270_to_v300.py b/src/openforms/config/migrations/0055_v270_to_v300.py new file mode 100644 index 0000000000..782a62a82d --- /dev/null +++ b/src/openforms/config/migrations/0055_v270_to_v300.py @@ -0,0 +1,684 @@ +# Generated by Django 4.2.17 on 2024-12-27 13:58 + +import functools +import re + +import django.core.validators +from django.db import migrations, models +from django.db.migrations.state import StateApps + +import tinymce.models + +import openforms.config.models.config +import openforms.emails.validators +import openforms.template.validators +import openforms.utils.translations +from openforms.utils.migrations_utils.fix_default_translation import ( + FixDefaultTranslations, +) + + +def replace_tag(tpl: str) -> str: + return re.sub( + r"{%\s*summary\s*%}", + "{% confirmation_summary %}", + tpl, + ) + + +def update_summary_tags(apps: StateApps, _): + GlobalConfiguration = apps.get_model("config", "GlobalConfiguration") + config = GlobalConfiguration.objects.first() + if config is None: + return + + # the cosign fields are new in 3.0.0 so they're not expected to hold the legacy + # tag. + config.submission_confirmation_template_en = replace_tag( + config.submission_confirmation_template_en + ) + config.submission_confirmation_template_nl = replace_tag( + config.submission_confirmation_template_nl + ) + config.confirmation_email_content_nl = replace_tag( + config.confirmation_email_content_nl + ) + config.confirmation_email_content_en = replace_tag( + config.confirmation_email_content_en + ) + config.save() + + +class Migration(migrations.Migration): + + replaces = [ + ( + "config", + "0055_globalconfiguration_email_verification_request_content_and_more", + ), + ("config", "0056_disable_prefill_objects_api_plugin"), + ("config", "0060_merge_20240920_1816"), + ("config", "0063_merge_20240923_1612"), + ("config", "0064_alter_globalconfiguration_submissions_removal_limit"), + ( + "config", + "0065_globalconfiguration_cosign_submission_confirmation_template_and_more", + ), + ( + "config", + "0066_alter_globalconfiguration_cosign_submission_confirmation_template_and_more", + ), + ( + "config", + "0067_globalconfiguration_cosign_confirmation_email_content_and_more", + ), + ("config", "0068_alter_globalconfiguration_cosign_request_template_and_more"), + ("config", "0068_update_summary_tags"), + ("config", "0069_maptilelayer"), + ] + + dependencies = [ + ("config", "0054_v250_to_v270"), + ] + + operations = [ + migrations.AddField( + model_name="globalconfiguration", + name="email_verification_request_content", + field=tinymce.models.HTMLField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/email_verification/request.html",), + **{} + ), + help_text="Content of the email verification email message.", + validators=[ + openforms.template.validators.DjangoTemplateValidator(), + openforms.emails.validators.URLSanitationValidator(), + ], + verbose_name="content", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="email_verification_request_content_en", + field=tinymce.models.HTMLField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/email_verification/request.html",), + **{} + ), + help_text="Content of the email verification email message.", + null=True, + validators=[ + openforms.template.validators.DjangoTemplateValidator(), + openforms.emails.validators.URLSanitationValidator(), + ], + verbose_name="content", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="email_verification_request_content_nl", + field=tinymce.models.HTMLField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/email_verification/request.html",), + **{} + ), + help_text="Content of the email verification email message.", + null=True, + validators=[ + openforms.template.validators.DjangoTemplateValidator(), + openforms.emails.validators.URLSanitationValidator(), + ], + verbose_name="content", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="email_verification_request_subject", + field=models.CharField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/email_verification/subject.txt",), + **{} + ), + help_text="Subject of the email verification email.", + max_length=1000, + validators=[openforms.template.validators.DjangoTemplateValidator()], + verbose_name="subject", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="email_verification_request_subject_en", + field=models.CharField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/email_verification/subject.txt",), + **{} + ), + help_text="Subject of the email verification email.", + max_length=1000, + null=True, + validators=[openforms.template.validators.DjangoTemplateValidator()], + verbose_name="subject", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="email_verification_request_subject_nl", + field=models.CharField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/email_verification/subject.txt",), + **{} + ), + help_text="Subject of the email verification email.", + max_length=1000, + null=True, + validators=[openforms.template.validators.DjangoTemplateValidator()], + verbose_name="subject", + ), + ), + migrations.AlterField( + model_name="globalconfiguration", + name="all_submissions_removal_limit", + field=models.PositiveIntegerField( + default=90, + help_text="Amount of days when all submissions will be permanently deleted", + validators=[django.core.validators.MinValueValidator(0)], + verbose_name="all submissions removal limit", + ), + ), + migrations.AlterField( + model_name="globalconfiguration", + name="errored_submissions_removal_limit", + field=models.PositiveIntegerField( + default=30, + help_text="Amount of days errored submissions will remain before being removed", + validators=[django.core.validators.MinValueValidator(0)], + verbose_name="errored submission removal limit", + ), + ), + migrations.AlterField( + model_name="globalconfiguration", + name="incomplete_submissions_removal_limit", + field=models.PositiveIntegerField( + default=7, + help_text="Amount of days incomplete submissions will remain before being removed", + validators=[django.core.validators.MinValueValidator(0)], + verbose_name="incomplete submission removal limit", + ), + ), + migrations.AlterField( + model_name="globalconfiguration", + name="successful_submissions_removal_limit", + field=models.PositiveIntegerField( + default=7, + help_text="Amount of days successful submissions will remain before being removed", + validators=[django.core.validators.MinValueValidator(0)], + verbose_name="successful submission removal limit", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="cosign_submission_confirmation_title", + field=models.CharField( + default=functools.partial( + openforms.utils.translations.get_default, + *("Request not complete yet",), + **{} + ), + help_text="The content of the confirmation page title for submissions requiring cosigning.", + max_length=200, + validators=[openforms.template.validators.DjangoTemplateValidator()], + verbose_name="cosign submission confirmation title", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="cosign_submission_confirmation_title_en", + field=models.CharField( + default=functools.partial( + openforms.utils.translations.get_default, + *("Request not complete yet",), + **{} + ), + help_text="The content of the confirmation page title for submissions requiring cosigning.", + max_length=200, + null=True, + validators=[openforms.template.validators.DjangoTemplateValidator()], + verbose_name="cosign submission confirmation title", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="cosign_submission_confirmation_title_nl", + field=models.CharField( + default=functools.partial( + openforms.utils.translations.get_default, + *("Request not complete yet",), + **{} + ), + help_text="The content of the confirmation page title for submissions requiring cosigning.", + max_length=200, + null=True, + validators=[openforms.template.validators.DjangoTemplateValidator()], + verbose_name="cosign submission confirmation title", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="submission_confirmation_title", + field=models.CharField( + default=functools.partial( + openforms.utils.translations.get_default, + *("Confirmation: {{ public_reference }}",), + **{} + ), + help_text="The content of the confirmation page title. You can (and should) use the 'public_reference' variable so the users have a reference in case they need to contact the customer service.", + max_length=200, + validators=[openforms.template.validators.DjangoTemplateValidator()], + verbose_name="submission confirmation title", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="submission_confirmation_title_en", + field=models.CharField( + default=functools.partial( + openforms.utils.translations.get_default, + *("Confirmation: {{ public_reference }}",), + **{} + ), + help_text="The content of the confirmation page title. You can (and should) use the 'public_reference' variable so the users have a reference in case they need to contact the customer service.", + max_length=200, + null=True, + validators=[openforms.template.validators.DjangoTemplateValidator()], + verbose_name="submission confirmation title", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="submission_confirmation_title_nl", + field=models.CharField( + default=functools.partial( + openforms.utils.translations.get_default, + *("Confirmation: {{ public_reference }}",), + **{} + ), + help_text="The content of the confirmation page title. You can (and should) use the 'public_reference' variable so the users have a reference in case they need to contact the customer service.", + max_length=200, + null=True, + validators=[openforms.template.validators.DjangoTemplateValidator()], + verbose_name="submission confirmation title", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="cosign_submission_confirmation_template", + field=tinymce.models.HTMLField( + default=functools.partial( + openforms.config.models.config._render, + *("config/default_cosign_submission_confirmation.html",), + **{} + ), + help_text="The content of the submission confirmation page for submissions requiring cosigning. The variables 'public_reference' and 'cosigner_email' are available. We strongly advise you to include the 'public_reference' in case users need to contact the customer service.", + validators=[ + openforms.template.validators.DjangoTemplateValidator( + backend="openforms.template.openforms_backend" + ) + ], + verbose_name="cosign submission confirmation template", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="cosign_submission_confirmation_template_en", + field=tinymce.models.HTMLField( + default=functools.partial( + openforms.config.models.config._render, + *("config/default_cosign_submission_confirmation.html",), + **{} + ), + help_text="The content of the submission confirmation page for submissions requiring cosigning. The variables 'public_reference' and 'cosigner_email' are available. We strongly advise you to include the 'public_reference' in case users need to contact the customer service.", + null=True, + validators=[ + openforms.template.validators.DjangoTemplateValidator( + backend="openforms.template.openforms_backend" + ) + ], + verbose_name="cosign submission confirmation template", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="cosign_submission_confirmation_template_nl", + field=tinymce.models.HTMLField( + default=functools.partial( + openforms.config.models.config._render, + *("config/default_cosign_submission_confirmation.html",), + **{} + ), + help_text="The content of the submission confirmation page for submissions requiring cosigning. The variables 'public_reference' and 'cosigner_email' are available. We strongly advise you to include the 'public_reference' in case users need to contact the customer service.", + null=True, + validators=[ + openforms.template.validators.DjangoTemplateValidator( + backend="openforms.template.openforms_backend" + ) + ], + verbose_name="cosign submission confirmation template", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="cosign_confirmation_email_content", + field=tinymce.models.HTMLField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/confirmation/cosign_content.html",), + **{} + ), + help_text="Content of the confirmation email message when the form requires cosigning. Can be overridden on the form level.", + validators=[ + openforms.template.validators.DjangoTemplateValidator( + backend="openforms.template.openforms_backend", + required_template_tags=[ + "payment_information", + "cosign_information", + ], + ), + openforms.emails.validators.URLSanitationValidator(), + ], + verbose_name="cosign content", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="cosign_confirmation_email_content_en", + field=tinymce.models.HTMLField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/confirmation/cosign_content.html",), + **{} + ), + help_text="Content of the confirmation email message when the form requires cosigning. Can be overridden on the form level.", + null=True, + validators=[ + openforms.template.validators.DjangoTemplateValidator( + backend="openforms.template.openforms_backend", + required_template_tags=[ + "payment_information", + "cosign_information", + ], + ), + openforms.emails.validators.URLSanitationValidator(), + ], + verbose_name="cosign content", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="cosign_confirmation_email_content_nl", + field=tinymce.models.HTMLField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/confirmation/cosign_content.html",), + **{} + ), + help_text="Content of the confirmation email message when the form requires cosigning. Can be overridden on the form level.", + null=True, + validators=[ + openforms.template.validators.DjangoTemplateValidator( + backend="openforms.template.openforms_backend", + required_template_tags=[ + "payment_information", + "cosign_information", + ], + ), + openforms.emails.validators.URLSanitationValidator(), + ], + verbose_name="cosign content", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="cosign_confirmation_email_subject", + field=models.CharField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/confirmation/cosign_subject.txt",), + **{} + ), + help_text="Subject of the confirmation email message when the form requires cosigning. Can be overridden on the form level.", + max_length=1000, + validators=[openforms.template.validators.DjangoTemplateValidator()], + verbose_name="cosign subject", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="cosign_confirmation_email_subject_en", + field=models.CharField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/confirmation/cosign_subject.txt",), + **{} + ), + help_text="Subject of the confirmation email message when the form requires cosigning. Can be overridden on the form level.", + max_length=1000, + null=True, + validators=[openforms.template.validators.DjangoTemplateValidator()], + verbose_name="cosign subject", + ), + ), + migrations.AddField( + model_name="globalconfiguration", + name="cosign_confirmation_email_subject_nl", + field=models.CharField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/confirmation/cosign_subject.txt",), + **{} + ), + help_text="Subject of the confirmation email message when the form requires cosigning. Can be overridden on the form level.", + max_length=1000, + null=True, + validators=[openforms.template.validators.DjangoTemplateValidator()], + verbose_name="cosign subject", + ), + ), + migrations.AlterField( + model_name="globalconfiguration", + name="confirmation_email_content", + field=tinymce.models.HTMLField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/confirmation/content.html",), + **{} + ), + help_text="Content of the confirmation email message. Can be overridden on the form level", + validators=[ + openforms.template.validators.DjangoTemplateValidator( + backend="openforms.template.openforms_backend", + required_template_tags=[ + "appointment_information", + "payment_information", + ], + ), + openforms.emails.validators.URLSanitationValidator(), + ], + verbose_name="content", + ), + ), + migrations.AlterField( + model_name="globalconfiguration", + name="confirmation_email_content_en", + field=tinymce.models.HTMLField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/confirmation/content.html",), + **{} + ), + help_text="Content of the confirmation email message. Can be overridden on the form level", + null=True, + validators=[ + openforms.template.validators.DjangoTemplateValidator( + backend="openforms.template.openforms_backend", + required_template_tags=[ + "appointment_information", + "payment_information", + ], + ), + openforms.emails.validators.URLSanitationValidator(), + ], + verbose_name="content", + ), + ), + migrations.AlterField( + model_name="globalconfiguration", + name="confirmation_email_content_nl", + field=tinymce.models.HTMLField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/confirmation/content.html",), + **{} + ), + help_text="Content of the confirmation email message. Can be overridden on the form level", + null=True, + validators=[ + openforms.template.validators.DjangoTemplateValidator( + backend="openforms.template.openforms_backend", + required_template_tags=[ + "appointment_information", + "payment_information", + ], + ), + openforms.emails.validators.URLSanitationValidator(), + ], + verbose_name="content", + ), + ), + migrations.AlterField( + model_name="globalconfiguration", + name="cosign_request_template", + field=tinymce.models.HTMLField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/co_sign/request.html",), + **{} + ), + help_text="Content of the co-sign request email. The available template variables are: 'form_name', 'submission_date', 'form_url' and 'code'.", + validators=[ + openforms.template.validators.DjangoTemplateValidator( + backend="openforms.template.openforms_backend" + ), + openforms.emails.validators.URLSanitationValidator(), + ], + verbose_name="co-sign request template", + ), + ), + migrations.AlterField( + model_name="globalconfiguration", + name="cosign_request_template_en", + field=tinymce.models.HTMLField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/co_sign/request.html",), + **{} + ), + help_text="Content of the co-sign request email. The available template variables are: 'form_name', 'submission_date', 'form_url' and 'code'.", + null=True, + validators=[ + openforms.template.validators.DjangoTemplateValidator( + backend="openforms.template.openforms_backend" + ), + openforms.emails.validators.URLSanitationValidator(), + ], + verbose_name="co-sign request template", + ), + ), + migrations.AlterField( + model_name="globalconfiguration", + name="cosign_request_template_nl", + field=tinymce.models.HTMLField( + default=functools.partial( + openforms.config.models.config._render, + *("emails/co_sign/request.html",), + **{} + ), + help_text="Content of the co-sign request email. The available template variables are: 'form_name', 'submission_date', 'form_url' and 'code'.", + null=True, + validators=[ + openforms.template.validators.DjangoTemplateValidator( + backend="openforms.template.openforms_backend" + ), + openforms.emails.validators.URLSanitationValidator(), + ], + verbose_name="co-sign request template", + ), + ), + migrations.RunPython( + FixDefaultTranslations( + app_label="config", + model="GlobalConfiguration", + fields=( + "cosign_submission_confirmation_template", + "cosign_submission_confirmation_title", + "submission_confirmation_title", + "cosign_confirmation_email_content", + "cosign_confirmation_email_subject", + ), + ), + migrations.RunPython.noop, + ), + migrations.RunPython( + code=update_summary_tags, + reverse_code=migrations.RunPython.noop, + ), + migrations.CreateModel( + name="MapTileLayer", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "identifier", + models.SlugField( + help_text="A unique identifier for the tile layer.", + unique=True, + verbose_name="identifier", + ), + ), + ( + "url", + models.URLField( + help_text="URL to the tile layer image, used to define the map component background. To ensure correct functionality of the map, EPSG 28992 projection should be used. Example value: https://service.pdok.nl/brt/achtergrondkaart/wmts/v2_0/standaard/EPSG:28992/{z}/{x}/{y}.png", + max_length=255, + verbose_name="tile layer url", + ), + ), + ( + "label", + models.CharField( + help_text="An easily recognizable name for the tile layer, used to identify it.", + max_length=100, + verbose_name="label", + ), + ), + ], + options={ + "verbose_name": "map tile layer", + "verbose_name_plural": "map tile layers", + "ordering": ("label",), + }, + ), + ] diff --git a/src/openforms/config/migrations/0068_update_summary_tags.py b/src/openforms/config/migrations/0068_update_summary_tags.py index c3ddc00912..30e91ca95a 100644 --- a/src/openforms/config/migrations/0068_update_summary_tags.py +++ b/src/openforms/config/migrations/0068_update_summary_tags.py @@ -1,40 +1,12 @@ # Generated by Django 4.2.16 on 2024-11-29 18:47 -import re from django.db import migrations -from django.db.migrations.state import StateApps +from django.utils.module_loading import import_string - -def replace_tag(tpl: str) -> str: - return re.sub( - r"{%\s*summary\s*%}", - "{% confirmation_summary %}", - tpl, - ) - - -def update_summary_tags(apps: StateApps, _): - GlobalConfiguration = apps.get_model("config", "GlobalConfiguration") - config = GlobalConfiguration.objects.first() - if config is None: - return - - # the cosign fields are new in 3.0.0 so they're not expected to hold the legacy - # tag. - config.submission_confirmation_template_en = replace_tag( - config.submission_confirmation_template_en - ) - config.submission_confirmation_template_nl = replace_tag( - config.submission_confirmation_template_nl - ) - config.confirmation_email_content_nl = replace_tag( - config.confirmation_email_content_nl - ) - config.confirmation_email_content_en = replace_tag( - config.confirmation_email_content_en - ) - config.save() +update_summary_tags = import_string( + "openforms.config.migrations.0055_v270_to_v300.update_summary_tags" +) class Migration(migrations.Migration):