diff --git a/src/open_inwoner/openklant/admin.py b/src/open_inwoner/openklant/admin.py index 71c7c180e2..9623284c62 100644 --- a/src/open_inwoner/openklant/admin.py +++ b/src/open_inwoner/openklant/admin.py @@ -8,8 +8,24 @@ from .models import ContactFormSubject, KlantContactMomentAnswer, OpenKlantConfig +class ContactFormSubjectForm(forms.ModelForm): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields["subject_code"].widget.attrs["placeholder"] = _( + "Must be configured if E-suite is used" + ) + + class Meta: + model = ContactFormSubject + fields = ( + "subject", + "subject_code", + ) + + class ContactFormSubjectInlineAdmin(OrderedTabularInline): model = ContactFormSubject + form = ContactFormSubjectForm fields = ("subject", "subject_code", "order", "move_up_down_links") readonly_fields = ("order", "move_up_down_links") ordering = ("order",) @@ -55,6 +71,7 @@ class OpenKlantConfigAdmin(OrderedInlineModelAdminMixin, SingletonModelAdmin): "register_contact_moment", "register_bronorganisatie_rsin", "register_type", + "register_channel", "register_employee_id", "use_rsin_for_innNnpId_query_parameter", ], diff --git a/src/open_inwoner/openklant/migrations/0010_openklantconfig_register_channel.py b/src/open_inwoner/openklant/migrations/0010_openklantconfig_register_channel.py new file mode 100644 index 0000000000..5a6c401c0d --- /dev/null +++ b/src/open_inwoner/openklant/migrations/0010_openklantconfig_register_channel.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.10 on 2024-03-20 15:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("openklant", "0009_klantcontactmomentanswer"), + ] + + operations = [ + migrations.AddField( + model_name="openklantconfig", + name="register_channel", + field=models.CharField( + blank=True, + default="contactformulier", + help_text="The channel through which contactmomenten are created", + max_length=50, + verbose_name="Contactmoment kanaal", + ), + ), + ] diff --git a/src/open_inwoner/openklant/models.py b/src/open_inwoner/openklant/models.py index 293d8b09d6..90a003c747 100644 --- a/src/open_inwoner/openklant/models.py +++ b/src/open_inwoner/openklant/models.py @@ -50,6 +50,13 @@ class OpenKlantConfig(SingletonModel): default="", blank=True, ) + register_channel = models.CharField( + verbose_name=_("Contactmoment kanaal"), + max_length=50, + default="contactformulier", + blank=True, + help_text=_("The channel through which contactmomenten are created"), + ) register_type = models.CharField( verbose_name=_("Contactmoment type"), max_length=50, diff --git a/src/open_inwoner/openklant/tests/test_contactform.py b/src/open_inwoner/openklant/tests/test_contactform.py index 432aa274a8..6cbb1798de 100644 --- a/src/open_inwoner/openklant/tests/test_contactform.py +++ b/src/open_inwoner/openklant/tests/test_contactform.py @@ -271,7 +271,7 @@ def test_submit_and_register_anon_via_api_with_klant(self, m): "bronorganisatie": "123456789", "tekst": "Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?", "type": "Melding", - "kanaal": "Internet", + "kanaal": "contactformulier", "onderwerp": "afdeling-xyz", }, ) @@ -294,6 +294,7 @@ def test_submit_and_register_anon_via_api_without_klant(self, m): config.register_contact_moment = True config.register_bronorganisatie_rsin = "123456789" config.register_type = "Melding" + config.register_channel = "contactformulier" config.register_employee_id = "FooVonBar" config.save() @@ -351,7 +352,7 @@ def test_submit_and_register_anon_via_api_without_klant(self, m): "bronorganisatie": "123456789", "tekst": text, "type": "Melding", - "kanaal": "Internet", + "kanaal": "contactformulier", "onderwerp": "afdeling-xyz", }, ) @@ -416,7 +417,7 @@ def test_submit_and_register_bsn_user_via_api(self, m): "bronorganisatie": "123456789", "tekst": "Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?", "type": "Melding", - "kanaal": "Internet", + "kanaal": "contactformulier", "onderwerp": "afdeling-xyz", }, ) @@ -506,7 +507,7 @@ def test_submit_and_register_kvk_or_rsin_user_via_api(self, _m): "bronorganisatie": "123456789", "tekst": "Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?", "type": "Melding", - "kanaal": "Internet", + "kanaal": "contactformulier", "onderwerp": "afdeling-xyz", }, ) @@ -582,7 +583,7 @@ def test_submit_and_register_bsn_user_via_api_and_update_klant(self, m): "bronorganisatie": "123456789", "tekst": "Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?", "type": "Melding", - "kanaal": "Internet", + "kanaal": "contactformulier", "onderwerp": "afdeling-xyz", }, ) @@ -678,7 +679,7 @@ def test_submit_and_register_kvk_or_rsin_user_via_api_and_update_klant(self, _m) "bronorganisatie": "123456789", "tekst": "Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?", "type": "Melding", - "kanaal": "Internet", + "kanaal": "contactformulier", "onderwerp": "afdeling-xyz", }, ) diff --git a/src/open_inwoner/openklant/views/contactform.py b/src/open_inwoner/openklant/views/contactform.py index d3706fea05..13a342d938 100644 --- a/src/open_inwoner/openklant/views/contactform.py +++ b/src/open_inwoner/openklant/views/contactform.py @@ -202,7 +202,7 @@ def register_by_api(self, form, config: OpenKlantConfig): "bronorganisatie": config.register_bronorganisatie_rsin, "tekst": text, "type": config.register_type, - "kanaal": "Internet", + "kanaal": config.register_channel, "onderwerp": subject_code or subject, "medewerkerIdentificatie": { "identificatie": config.register_employee_id,