Skip to content

Commit

Permalink
[#2578] Add optional help text field for monthly benefits reports
Browse files Browse the repository at this point in the history
  • Loading branch information
pi-sigma committed Jun 26, 2024
1 parent a2906c1 commit 484d341
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/open_inwoner/ssd/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class SSDConfigAdmin(SingletonModelAdmin):
"maandspecificatie_delta",
"maandspecificatie_available_from",
"maandspecificatie_display_text",
"maandspecificatie_pdf_comments",
)
},
),
Expand All @@ -42,7 +43,7 @@ class SSDConfigAdmin(SingletonModelAdmin):
"jaaropgave_delta",
"jaaropgave_available_from",
"jaaropgave_display_text",
"jaaropgave_comments",
"jaaropgave_pdf_comments",
)
},
),
Expand Down
5 changes: 4 additions & 1 deletion src/open_inwoner/ssd/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ def get_reports(
)
pdf = render_pdf(
self.html_template,
context={"reports": uitkeringen},
context={
"reports": uitkeringen,
"comments": self.config.maandspecificatie_pdf_comments,
},
base_url=request_base_url,
)
return pdf
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 4.2.11 on 2024-06-26 14:23

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("ssd", "0005_fix_translations_typo"),
]

operations = [
migrations.RenameField(
model_name="ssdconfig",
old_name="jaaropgave_comments",
new_name="jaaropgave_pdf_comments",
),
migrations.AddField(
model_name="ssdconfig",
name="maandspecificatie_pdf_comments",
field=models.TextField(
blank=True,
help_text="Optional comments to be included in the maandspecificatie PDF. Markdown formatting is supported.",
verbose_name="PDF help text",
),
),
]
10 changes: 9 additions & 1 deletion src/open_inwoner/ssd/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class SSDConfig(SingletonModel):
blank=True,
help_text=_("The text displayed as overview of the 'Jaaropgave' tab"),
)
jaaropgave_comments = models.TextField(
jaaropgave_pdf_comments = models.TextField(
_("PDF help text"),
blank=True,
help_text=_("Help text for the columns in the Jaaropgave PDF"),
Expand All @@ -110,6 +110,14 @@ class SSDConfig(SingletonModel):
blank=True,
help_text=_("The text displayed as overview of the 'Maandspecificatie' tab"),
)
maandspecificatie_pdf_comments = models.TextField(
_("PDF help text"),
blank=True,
help_text=_(
"Optional comments to be included in the maandspecificatie PDF. "
"Markdown formatting is supported."
),
)

@property
def logo(self):
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/ssd/templates/jaaropgave.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ <h2 class="utrecht-heading-2">Participatiewet</h2>
<!-- TOELICHTING -->
<section class="section section__toelichting extra-margin">
<div class="subsection extra-margin">
<p class="yearly-report__p yearly-report__comments" >{{ report.jaaropgave_comments|markdown|safe }}</p>
<p class="yearly-report__p yearly-report__comments" >{{ report.jaaropgave_pdf_comments|markdown|safe }}</p>
</div>
</section>
</div>
Expand Down
9 changes: 8 additions & 1 deletion src/open_inwoner/ssd/templates/maandspecificatie.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load ssd_tags l10n %}
{% load ssd_tags utils static l10n %}

<!DOCTYPE html>
<html lang="nl">
Expand Down Expand Up @@ -157,6 +157,13 @@ <h2 class="utrecht-heading-2 section-title">Inkomstenkorting</h2>
<p class="monthly-report__p extra-margin">Op de 25e van de maand krijgt u het bedrag ad. &euro; {% format_currency last.bedrag.waarde_bedrag %} uitbetaald.</p>
</div>
{% endif %}

{# Optional comments/help text #}
{% if comments %}
<section class="section">
{{ comments|markdown|safe }}
</section>
{% endif %}
</div>
</body>
<p style="page-break-after: always;">&nbsp;</p>
Expand Down
15 changes: 14 additions & 1 deletion src/open_inwoner/ssd/tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pyquery import PyQuery

from ..client import UitkeringClient
from ..models import SSDConfig
from ..service.uitkering import (
UitkeringsSpecificatieInfoResponse as UitkeringInfoResponse,
)
Expand All @@ -31,9 +32,21 @@ def test_template_uitkering_basic(self, m):
uitkering_path, UITKERING_INFO_RESPONSE_NODE, UitkeringInfoResponse
)

config = SSDConfig.get_solo()
config.maandspecificatie_pdf_comments = "Lorem ipsum dolor sit amet..."
config.save()

uitkeringen = get_uitkeringen(None)

html = render_html(ssd_client.html_template, context={"reports": uitkeringen})
html = render_html(
ssd_client.html_template,
context={
"reports": uitkeringen,
"comments": config.maandspecificatie_pdf_comments,
},
)

self.assertIn("Lorem ipsum dolor sit amet...", html)

doc = PyQuery(html)

Expand Down

0 comments on commit 484d341

Please sign in to comment.