From d23d5cfb0cf9c76dd52188a1cb41dae806c171f6 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Mon, 1 Jul 2024 19:32:29 +0200 Subject: [PATCH] :recyle: [#4246] Rename python attribute to better name The value will need to be updated too, but that will involve some migrations and import shims to update the prefill configuration. --- ...er_formvariable_prefill_identifier_role.py | 24 +++++++++++++++++++ src/openforms/prefill/constants.py | 7 +++++- .../contrib/haalcentraal_brp/plugin.py | 2 +- .../haalcentraal_brp/tests/test_plugin.py | 2 +- .../prefill/contrib/stufbg/plugin.py | 2 +- .../contrib/stufbg/tests/test_plugin.py | 2 +- .../prefill/tests/test_prefill_hook.py | 6 ++--- 7 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 src/openforms/forms/migrations/0102_alter_formvariable_prefill_identifier_role.py diff --git a/src/openforms/forms/migrations/0102_alter_formvariable_prefill_identifier_role.py b/src/openforms/forms/migrations/0102_alter_formvariable_prefill_identifier_role.py new file mode 100644 index 0000000000..6ec8ad279f --- /dev/null +++ b/src/openforms/forms/migrations/0102_alter_formvariable_prefill_identifier_role.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.11 on 2024-07-02 06:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("forms", "0101_objecttype_url_to_uuid"), + ] + + operations = [ + migrations.AlterField( + model_name="formvariable", + name="prefill_identifier_role", + field=models.CharField( + choices=[("main", "Main"), ("authorised_person", "Authorizee")], + default="main", + help_text="In case that multiple identifiers are returned (in the case of eHerkenning bewindvoering and DigiD Machtigen), should the prefill data related to the main identifier be used, or that related to the authorised person?", + max_length=100, + verbose_name="prefill identifier role", + ), + ), + ] diff --git a/src/openforms/prefill/constants.py b/src/openforms/prefill/constants.py index c988535d1a..7b2d20385d 100644 --- a/src/openforms/prefill/constants.py +++ b/src/openforms/prefill/constants.py @@ -4,4 +4,9 @@ class IdentifierRoles(models.TextChoices): main = "main", _("Main") - authorised_person = "authorised_person", _("Authorised person") + # TODO: this value is wrongly named: + # 1. authorised person only applies for DigiD machtigen + # 2. with eHerkenning (bewindvoering), the authorizee is de *company* (legal + # subject). For the acting subject, we only get an opaque, encrypted identifier + # that cannot be used to prefill information (this is by design). + authorizee = "authorised_person", _("Authorizee") diff --git a/src/openforms/prefill/contrib/haalcentraal_brp/plugin.py b/src/openforms/prefill/contrib/haalcentraal_brp/plugin.py index 0e8441374a..4045a85dc4 100644 --- a/src/openforms/prefill/contrib/haalcentraal_brp/plugin.py +++ b/src/openforms/prefill/contrib/haalcentraal_brp/plugin.py @@ -90,7 +90,7 @@ def get_identifier_value( ): return submission.auth_info.value - if identifier_role == IdentifierRoles.authorised_person: + if identifier_role == IdentifierRoles.authorizee: return submission.auth_info.machtigen.get("identifier_value") @classmethod diff --git a/src/openforms/prefill/contrib/haalcentraal_brp/tests/test_plugin.py b/src/openforms/prefill/contrib/haalcentraal_brp/tests/test_plugin.py index e0418a9067..fb5999ff5d 100644 --- a/src/openforms/prefill/contrib/haalcentraal_brp/tests/test_plugin.py +++ b/src/openforms/prefill/contrib/haalcentraal_brp/tests/test_plugin.py @@ -146,7 +146,7 @@ def test_prefill_values_for_gemachtigde(self): values = plugin.get_prefill_values( submission, attributes=[Attributes.naam_voornamen, Attributes.naam_geslachtsnaam], - identifier_role=IdentifierRoles.authorised_person, + identifier_role=IdentifierRoles.authorizee, ) self.assertEqual( diff --git a/src/openforms/prefill/contrib/stufbg/plugin.py b/src/openforms/prefill/contrib/stufbg/plugin.py index 4a0f8ba92d..bb00bea092 100644 --- a/src/openforms/prefill/contrib/stufbg/plugin.py +++ b/src/openforms/prefill/contrib/stufbg/plugin.py @@ -142,7 +142,7 @@ def get_identifier_value( ): return submission.auth_info.value - if identifier_role == IdentifierRoles.authorised_person: + if identifier_role == IdentifierRoles.authorizee: return submission.auth_info.machtigen.get("identifier_value") @classmethod diff --git a/src/openforms/prefill/contrib/stufbg/tests/test_plugin.py b/src/openforms/prefill/contrib/stufbg/tests/test_plugin.py index 9aa0a230ba..fa3972ce4c 100644 --- a/src/openforms/prefill/contrib/stufbg/tests/test_plugin.py +++ b/src/openforms/prefill/contrib/stufbg/tests/test_plugin.py @@ -229,7 +229,7 @@ def test_get_available_attributes_for_gemachtigde(self): ) values = self.plugin.get_prefill_values( - submission, attributes, IdentifierRoles.authorised_person + submission, attributes, IdentifierRoles.authorizee ) self.assertEqual(values["bsn"], "999992314") diff --git a/src/openforms/prefill/tests/test_prefill_hook.py b/src/openforms/prefill/tests/test_prefill_hook.py index 2be33e6a01..b63968c8c8 100644 --- a/src/openforms/prefill/tests/test_prefill_hook.py +++ b/src/openforms/prefill/tests/test_prefill_hook.py @@ -140,7 +140,7 @@ def test_fetch_values_with_multiple_people(self, m_haal_centraal): "prefill": { "plugin": "haalcentraal", "attribute": "naam.geslachtsnaam", - "identifierRole": IdentifierRoles.authorised_person, + "identifierRole": IdentifierRoles.authorizee, }, }, ] @@ -185,7 +185,7 @@ def test_fetch_values_with_legal_entity_and_person(self, m_kvk, m_haal_centraal) "prefill": { "plugin": "haalcentraal", "attribute": "naam.geslachtsnaam", - "identifier": IdentifierRoles.authorised_person, + "identifier": IdentifierRoles.authorizee, }, }, { @@ -194,7 +194,7 @@ def test_fetch_values_with_legal_entity_and_person(self, m_kvk, m_haal_centraal) "prefill": { "plugin": "haalcentraal", "attribute": "naam.voornamen", - "identifier": IdentifierRoles.authorised_person, + "identifier": IdentifierRoles.authorizee, }, }, ]