Skip to content

Commit

Permalink
🗃️ [#4320] Add new configuration fields for cosign content
Browse files Browse the repository at this point in the history
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!)
  • Loading branch information
sergei-maertens committed Nov 12, 2024
1 parent 499e0d8 commit 4b3edb0
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/openforms/config/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class GlobalConfigurationAdmin(TranslationAdmin, SingletonModelAdmin):
_("Submissions"),
{
"fields": (
"submission_confirmation_title",
"submission_confirmation_template",
"submission_report_download_link_title",
),
Expand All @@ -46,6 +47,15 @@ class GlobalConfigurationAdmin(TranslationAdmin, SingletonModelAdmin):
),
},
),
(
_("Submissions with cosigning"),
{
"fields": (
"cosign_submission_confirmation_title",
"cosign_submission_confirmation_template",
),
},
),
(
_("Co-sign emails"),
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
),
),
]
32 changes: 32 additions & 0 deletions src/openforms/config/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=_(
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% load i18n capture_tags %}
{% capture as tt_openvariable silent %}{% templatetag openvariable %}{% endcapture %}
{% capture as tt_closevariable silent %}{% templatetag closevariable %}{% endcapture %}
<p>{% trans "Your request is not yet complete." %}</p>
<h2>{% trans "Cosigning required" %}</h2>
<p>{% blocktrans trimmed %}
We've sent an email with a cosign request to
<a href="mailto:{{ tt_openvariable }} cosigner_email {{ tt_closevariable }}">{{ tt_openvariable }} cosigner_email {{ tt_closevariable }}</a>.
Once the submission has been cosigned we will start processing your request.
{% endblocktrans %}</p>
<p>{% blocktrans trimmed %}
If you need to contact us about this submission, you can use the reference
<strong>{{ tt_openvariable }} public_reference {{ tt_closevariable }}</strong>{% endblocktrans %}.
</p>
6 changes: 6 additions & 0 deletions src/openforms/config/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": "",
Expand Down

0 comments on commit 4b3edb0

Please sign in to comment.