Skip to content

Commit 116e0ab

Browse files
authored
Merge pull request #857 from maykinmedia/issue-1860-prefix-subject-in-contactmoment
[#1860] Prefixing subject with "Onderwerp"
2 parents 4740bcf + fd31393 commit 116e0ab

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

src/open_inwoner/openklant/tests/test_contactform.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def test_submit_and_register_anon_via_api_with_klant(self, m):
263263
{
264264
"medewerkerIdentificatie": {"identificatie": "FooVonBar"},
265265
"bronorganisatie": "123456789",
266-
"tekst": f"Aanvraag document\n\nhey!\n\nwaddup?",
266+
"tekst": f"Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?",
267267
"type": "Melding",
268268
"kanaal": "Internet",
269269
"onderwerp": "afdeling-xyz",
@@ -325,7 +325,7 @@ def test_submit_and_register_anon_via_api_without_klant(self, m):
325325

326326
text = inspect.cleandoc(
327327
"""
328-
Aanvraag document
328+
Onderwerp: Aanvraag document
329329
330330
hey!
331331
@@ -407,7 +407,7 @@ def test_submit_and_register_bsn_user_via_api(self, m):
407407
{
408408
"medewerkerIdentificatie": {"identificatie": "FooVonBar"},
409409
"bronorganisatie": "123456789",
410-
"tekst": f"Aanvraag document\n\nhey!\n\nwaddup?",
410+
"tekst": f"Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?",
411411
"type": "Melding",
412412
"kanaal": "Internet",
413413
"onderwerp": "afdeling-xyz",
@@ -482,7 +482,7 @@ def test_submit_and_register_bsn_user_via_api_and_update_klant(self, m):
482482
{
483483
"medewerkerIdentificatie": {"identificatie": "FooVonBar"},
484484
"bronorganisatie": "123456789",
485-
"tekst": f"Aanvraag document\n\nhey!\n\nwaddup?",
485+
"tekst": f"Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?",
486486
"type": "Melding",
487487
"kanaal": "Internet",
488488
"onderwerp": "afdeling-xyz",

src/open_inwoner/openklant/views/contactform.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ def register_by_api(self, form, config: OpenKlantConfig):
131131
if update_data:
132132
patch_klant(klant, update_data)
133133
self.log_system_action(
134-
f"patched klant from user with missing fields: {', '.join(sorted(update_data.keys()))}",
134+
"patched klant from user with missing fields: {patched}".format(
135+
patched=", ".join(sorted(update_data.keys()))
136+
),
135137
user=self.request.user,
136138
)
137139
else:
@@ -148,7 +150,8 @@ def register_by_api(self, form, config: OpenKlantConfig):
148150
"emailadres": form.cleaned_data["email"],
149151
"telefoonnummer": form.cleaned_data["phonenumber"],
150152
}
151-
# registering klanten won't work in e-Suite as it always pulls from BRP (but try anyway and fallback to appending details to tekst if fails)
153+
# registering klanten won't work in e-Suite as it always pulls from BRP
154+
# (but try anyway and fallback to appending details to tekst if fails)
152155
klant = create_klant(data)
153156
if klant:
154157
if self.request.user.is_authenticated:
@@ -163,19 +166,27 @@ def register_by_api(self, form, config: OpenKlantConfig):
163166
subject = form.cleaned_data["subject"].subject
164167
subject_code = form.cleaned_data["subject"].subject_code
165168
question = form.cleaned_data["question"]
166-
text = f"{subject}\n\n{question}"
169+
text = _("Onderwerp: {subject}\n\n{question}").format(
170+
subject=subject, question=question
171+
)
167172

168173
if not klant:
169174
# if we don't have a BSN and can't create a Klant we'll add contact info to the tekst
170175
parts = [form.cleaned_data[k] for k in ("first_name", "infix", "last_name")]
171176
full_name = " ".join(p for p in parts if p)
172-
text = f"{text}\n\nNaam: {full_name}"
177+
text = _("{text}\n\nNaam: {full_name}").format(
178+
text=text, full_name=full_name
179+
)
173180

174181
if form.cleaned_data["email"]:
175-
text = f"{text}\nEmail: {form.cleaned_data['email']}"
182+
text = _("{text}\nEmail: {email}").format(
183+
text=text, email=form.cleaned_data["email"]
184+
)
176185

177186
if form.cleaned_data["phonenumber"]:
178-
text = f"{text}\nTelefoonnummer: {form.cleaned_data['phonenumber']}"
187+
text = _("{text}\nTelefoonnummer: {phone}").format(
188+
text=text, phone=form.cleaned_data["phonenumber"]
189+
)
179190

180191
self.log_system_action(
181192
"could not retrieve or create klant for user, appended info to message",

0 commit comments

Comments
 (0)