From 4b3edb0febca42a9e63f92eac078267ac7ff9442 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Tue, 12 Nov 2024 18:53:01 +0100 Subject: [PATCH] :card_file_box: [#4320] Add new configuration fields for cosign content Added title and confirmation page configuration fields to control what is displayed on the confirmation page in the SDK. The runtime code will select the appropriate template depending on whether cosigning is required for the submission or not (it may be optional through form logic!) --- src/openforms/config/admin.py | 10 ++ ...bmission_confirmation_template_and_more.py | 153 ++++++++++++++++++ src/openforms/config/models/config.py | 32 ++++ ...efault_cosign_submission_confirmation.html | 14 ++ src/openforms/config/translation.py | 6 + 5 files changed, 215 insertions(+) create mode 100644 src/openforms/config/migrations/0064_globalconfiguration_cosign_submission_confirmation_template_and_more.py create mode 100644 src/openforms/config/templates/config/default_cosign_submission_confirmation.html diff --git a/src/openforms/config/admin.py b/src/openforms/config/admin.py index eb75e036d8..689b721757 100644 --- a/src/openforms/config/admin.py +++ b/src/openforms/config/admin.py @@ -26,6 +26,7 @@ class GlobalConfigurationAdmin(TranslationAdmin, SingletonModelAdmin): _("Submissions"), { "fields": ( + "submission_confirmation_title", "submission_confirmation_template", "submission_report_download_link_title", ), @@ -46,6 +47,15 @@ class GlobalConfigurationAdmin(TranslationAdmin, SingletonModelAdmin): ), }, ), + ( + _("Submissions with cosigning"), + { + "fields": ( + "cosign_submission_confirmation_title", + "cosign_submission_confirmation_template", + ), + }, + ), ( _("Co-sign emails"), { diff --git a/src/openforms/config/migrations/0064_globalconfiguration_cosign_submission_confirmation_template_and_more.py b/src/openforms/config/migrations/0064_globalconfiguration_cosign_submission_confirmation_template_and_more.py new file mode 100644 index 0000000000..3e7f37d245 --- /dev/null +++ b/src/openforms/config/migrations/0064_globalconfiguration_cosign_submission_confirmation_template_and_more.py @@ -0,0 +1,153 @@ +# Generated by Django 4.2.16 on 2024-11-12 17:46 + +import functools + +from django.db import migrations, models + +import tinymce.models + +import openforms.config.models.config +import openforms.template.validators +import openforms.utils.translations + + +class Migration(migrations.Migration): + + dependencies = [ + ("config", "0063_merge_20240923_1612"), + ] + + operations = [ + 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()], + 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()], + 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()], + verbose_name="cosign submission confirmation template", + ), + ), + 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.", + 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.", + 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.", + 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: {{ 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.", + 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: {{ 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.", + 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: {{ 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.", + null=True, + validators=[openforms.template.validators.DjangoTemplateValidator()], + verbose_name="submission confirmation title", + ), + ), + ] diff --git a/src/openforms/config/models/config.py b/src/openforms/config/models/config.py index d8780bc85b..e87f0bf3dd 100644 --- a/src/openforms/config/models/config.py +++ b/src/openforms/config/models/config.py @@ -61,6 +61,17 @@ class GlobalConfiguration(SingletonModel): default=list, ) + # Confirmation page content + submission_confirmation_title = models.CharField( + _("submission confirmation title"), + 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." + ), + default=runtime_gettext(_("Confirmation: {{ reference }}")), + validators=[DjangoTemplateValidator()], + ) submission_confirmation_template = HTMLField( _("submission confirmation template"), help_text=_( @@ -76,7 +87,28 @@ class GlobalConfiguration(SingletonModel): help_text=_("The title of the link to download the report of a submission."), default=runtime_gettext(_("Download PDF")), ) + cosign_submission_confirmation_title = models.CharField( + _("cosign submission confirmation title"), + help_text=_( + "The content of the confirmation page title for submissions requiring " + "cosigning." + ), + default=runtime_gettext(_("Request not complete yet")), + validators=[DjangoTemplateValidator()], + ) + cosign_submission_confirmation_template = HTMLField( + _("cosign submission confirmation template"), + 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." + ), + default=partial(_render, "config/default_cosign_submission_confirmation.html"), + validators=[DjangoTemplateValidator()], + ) + # Email templates confirmation_email_subject = models.CharField( _("subject"), max_length=1000, diff --git a/src/openforms/config/templates/config/default_cosign_submission_confirmation.html b/src/openforms/config/templates/config/default_cosign_submission_confirmation.html new file mode 100644 index 0000000000..5896ac5ae4 --- /dev/null +++ b/src/openforms/config/templates/config/default_cosign_submission_confirmation.html @@ -0,0 +1,14 @@ +{% load i18n capture_tags %} +{% capture as tt_openvariable silent %}{% templatetag openvariable %}{% endcapture %} +{% capture as tt_closevariable silent %}{% templatetag closevariable %}{% endcapture %} +

{% trans "Your request is not yet complete." %}

+

{% trans "Cosigning required" %}

+

{% blocktrans trimmed %} + We've sent an email with a cosign request to + {{ tt_openvariable }} cosigner_email {{ tt_closevariable }}. + Once the submission has been cosigned we will start processing your request. +{% endblocktrans %}

+

{% blocktrans trimmed %} + If you need to contact us about this submission, you can use the reference + {{ tt_openvariable }} public_reference {{ tt_closevariable }}{% endblocktrans %}. +

diff --git a/src/openforms/config/translation.py b/src/openforms/config/translation.py index 28e60d9e3c..ed6c405e24 100644 --- a/src/openforms/config/translation.py +++ b/src/openforms/config/translation.py @@ -6,7 +6,10 @@ @register(GlobalConfiguration) class GlobalConfigurationTranslationOptions(TranslationOptions): fields = ( + "submission_confirmation_title", "submission_confirmation_template", + "cosign_submission_confirmation_title", + "cosign_submission_confirmation_template", "submission_report_download_link_title", "confirmation_email_subject", "confirmation_email_content", @@ -26,7 +29,10 @@ class GlobalConfigurationTranslationOptions(TranslationOptions): "statement_of_truth_label", ) fallback_undefined = { + "submission_confirmation_title": "", "submission_confirmation_template": "", + "cosign_submission_confirmation_title": "", + "cosign_submission_confirmation_template": "", "submission_report_download_link_title": "", "confirmation_email_subject": "", "confirmation_email_content": "",