Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2761] Map contact data of anonymous contactmoment to E-suite fields #1405

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/open_inwoner/openklant/tests/test_contactform.py
Original file line number Diff line number Diff line change
@@ -286,6 +286,10 @@ def test_submit_and_register_anon_via_api_with_klant(self, m, mock_send_confirm)
"type": "Melding",
"kanaal": "contactformulier",
"onderwerp": "afdeling-xyz",
"contactgegevens": {
"emailadres": "[email protected]",
"telefoonnummer": "+31612345678",
},
},
)
kcm_create_data = data.matchers[2].request_history[0].json()
@@ -353,8 +357,6 @@ def test_submit_and_register_anon_via_api_without_klant(self, m, mock_send_confi
waddup?

Naam: Foo de Bar
Email: [email protected]
Telefoonnummer: +31612345678
"""
)

@@ -367,6 +369,10 @@ def test_submit_and_register_anon_via_api_without_klant(self, m, mock_send_confi
"type": "Melding",
"kanaal": "contactformulier",
"onderwerp": "afdeling-xyz",
"contactgegevens": {
"emailadres": "[email protected]",
"telefoonnummer": "+31612345678",
},
},
)
self.assertTimelineLog(
@@ -682,6 +688,7 @@ def test_submit_and_register_bsn_user_via_api_and_update_klant(
def test_submit_and_register_kvk_or_rsin_user_via_api_and_update_klant(
self, _m, mock_send_confirm
):
self.maxDiff = None
MockAPICreateData.setUpServices()

config = OpenKlantConfig.get_solo()
19 changes: 7 additions & 12 deletions src/open_inwoner/openklant/views/contactform.py
Original file line number Diff line number Diff line change
@@ -194,8 +194,6 @@ def register_by_api(self, form, config: OpenKlantConfig) -> tuple[bool, str]:
"emailadres": form.cleaned_data["email"],
"telefoonnummer": form.cleaned_data["phonenumber"],
}
# 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)
klant = klanten_client.create_klant(data=data)

if klant:
@@ -222,16 +220,6 @@ def register_by_api(self, form, config: OpenKlantConfig) -> tuple[bool, str]:
text=text, full_name=full_name
)

if form.cleaned_data["email"]:
text = _("{text}\nEmail: {email}").format(
text=text, email=form.cleaned_data["email"]
)

if form.cleaned_data["phonenumber"]:
text = _("{text}\nTelefoonnummer: {phone}").format(
text=text, phone=form.cleaned_data["phonenumber"]
)

self.log_system_action(
"could not retrieve or create klant for user, appended info to message",
user=self.request.user,
@@ -244,6 +232,13 @@ def register_by_api(self, form, config: OpenKlantConfig) -> tuple[bool, str]:
"kanaal": config.register_channel,
"onderwerp": subject_code or subject,
}

if not self.request.user.is_authenticated:
data["contactgegevens"] = {
"emailadres": form.cleaned_data["email"],
"telefoonnummer": form.cleaned_data["phonenumber"],
}

if employee_id := config.register_employee_id:
data["medewerkerIdentificatie"] = {"identificatie": employee_id}