From 466e84069a652e638502ead6709ec49ff85f4cb8 Mon Sep 17 00:00:00 2001 From: SilviaAmAm Date: Tue, 11 Jul 2023 10:37:44 +0200 Subject: [PATCH] :ok_hand: [#3215] PR Feedback 1 --- docs/manual/forms/form_fields.rst | 4 ++-- .../contrib/digid_eherkenning_oidc/plugin.py | 2 +- .../form_design/variables/VariablesTable.js | 6 ++++-- .../admin/form_design/variables/constants.js | 16 +++++++++++++++- src/openforms/prefill/__init__.py | 5 +---- src/openforms/prefill/tests/test_prefill_hook.py | 4 ++-- 6 files changed, 25 insertions(+), 12 deletions(-) diff --git a/docs/manual/forms/form_fields.rst b/docs/manual/forms/form_fields.rst index 1d0ccc34de..462449fe44 100644 --- a/docs/manual/forms/form_fields.rst +++ b/docs/manual/forms/form_fields.rst @@ -136,8 +136,8 @@ Prefill ------- * **Plugin**: Welke prefill plugin te gebruiken om data op te halen over de persoon/het bedrijf die ingelogd is. -* **Pluginattribuut**: Welke attribuut van de prefill-backend data te gebruiken om deze component te prefillen. -* **Identifier rol**: In het geval dat de gebruiker met DigiD Machtigen en eHerkenning Bewindvoering heeft ingelogd, moeten de gegevens gerelateerd aan het 'hoofd identifier' worden gebruikt, of die gerelateerd aan de gemachtigde persoon? +* **Pluginattribuut**: Welk attribuut van de prefill-backend data te gebruiken om deze component voorin te vullen. +* **Identifier rol**: In het geval dat de gebruiker met DigiD Machtigen of eHerkenning Bewindvoering heeft ingelogd: van welke rol moeten de gegevens gebruikt worden, die van de 'hoofd identifier' worden gebruikt, of die van de gemachtigde persoon? Globale configuratieopties diff --git a/src/openforms/authentication/contrib/digid_eherkenning_oidc/plugin.py b/src/openforms/authentication/contrib/digid_eherkenning_oidc/plugin.py index 56d6a82070..6efc464a81 100644 --- a/src/openforms/authentication/contrib/digid_eherkenning_oidc/plugin.py +++ b/src/openforms/authentication/contrib/digid_eherkenning_oidc/plugin.py @@ -155,7 +155,7 @@ def add_claims_to_sessions_if_not_cosigning(self, claim, request): if not claim or CO_SIGN_PARAMETER in request.GET: return - config = OpenIDConnectDigiDMachtigenConfig.get_solo() + config = self.config_class.get_solo() machtigen_data = request.session[DIGID_MACHTIGEN_OIDC_AUTH_SESSION_KEY] request.session[FORM_AUTH_SESSION_KEY] = { "plugin": self.identifier, diff --git a/src/openforms/js/components/admin/form_design/variables/VariablesTable.js b/src/openforms/js/components/admin/form_design/variables/VariablesTable.js index b456a3ab3a..b04e97776e 100644 --- a/src/openforms/js/components/admin/form_design/variables/VariablesTable.js +++ b/src/openforms/js/components/admin/form_design/variables/VariablesTable.js @@ -14,7 +14,7 @@ import Select from 'components/admin/forms/Select'; import {ChangelistTableWrapper, HeadColumn} from 'components/admin/tables'; import {get} from 'utils/fetch'; -import {DATATYPES_CHOICES, IDENTIFIER_ROLE_CHOICES} from './constants'; +import {DATATYPES_CHOICES, IDENTIFIER_ROLE_CHOICES, IDENTIFIER_ROLE_LABELS} from './constants'; import Variable from './types'; import {variableHasErrors} from './utils'; @@ -89,7 +89,9 @@ const VariableRow = ({index, variable}) => { {getFormDefinitionName(variable.formDefinition)} {variable.prefillPlugin} {variable.prefillAttribute} - {variable.prefillIdentifierRole || 'main'} + + {IDENTIFIER_ROLE_LABELS[variable.prefillIdentifierRole] || IDENTIFIER_ROLE_LABELS.main} + {variable.dataType} diff --git a/src/openforms/js/components/admin/form_design/variables/constants.js b/src/openforms/js/components/admin/form_design/variables/constants.js index fde3045937..d2b23ecfac 100644 --- a/src/openforms/js/components/admin/form_design/variables/constants.js +++ b/src/openforms/js/components/admin/form_design/variables/constants.js @@ -1,4 +1,5 @@ -import {defineMessage} from 'react-intl'; +import React from 'react'; +import {FormattedMessage, defineMessage} from 'react-intl'; const COMPONENT_DATATYPES = { date: 'date', @@ -115,10 +116,23 @@ const IDENTIFIER_ROLE_CHOICES = [ ], ]; +const IDENTIFIER_ROLE_LABELS = { + main: ( + + ), + authorised_person: ( + + ), +}; + export { COMPONENT_DATATYPES, VARIABLE_SOURCES, DATATYPES_CHOICES, EMPTY_VARIABLE, IDENTIFIER_ROLE_CHOICES, + IDENTIFIER_ROLE_LABELS, }; diff --git a/src/openforms/prefill/__init__.py b/src/openforms/prefill/__init__.py index de8b903936..ea9d94d38a 100644 --- a/src/openforms/prefill/__init__.py +++ b/src/openforms/prefill/__init__.py @@ -151,10 +151,7 @@ def prefill_variables(submission: "Submission", register=None) -> None: attribute_name = variable.form_variable.prefill_attribute identifier_role = variable.form_variable.prefill_identifier_role - if not grouped_fields[plugin_id].get(identifier_role): - grouped_fields[plugin_id][identifier_role] = [] - - grouped_fields[plugin_id][identifier_role].append(attribute_name) + grouped_fields[plugin_id].setdefault(identifier_role, []).append(attribute_name) results = _fetch_prefill_values(grouped_fields, submission, register) diff --git a/src/openforms/prefill/tests/test_prefill_hook.py b/src/openforms/prefill/tests/test_prefill_hook.py index 7aa5dd5a50..da946e05bd 100644 --- a/src/openforms/prefill/tests/test_prefill_hook.py +++ b/src/openforms/prefill/tests/test_prefill_hook.py @@ -120,7 +120,7 @@ class PrefillHookTests(TransactionTestCase): "openforms.prefill.contrib.haalcentraal.plugin.HaalCentraalPrefill.get_prefill_values", return_value={"naam.voornamen": "John", "naam.geslachtsnaam": "Dodo"}, ) - def test_fetch_values_with_multiple_bsn(self, m_bsn): + def test_fetch_values_with_multiple_people(self, m_haal_centraal): components = [ { "key": "mainPersonName", @@ -165,7 +165,7 @@ def test_fetch_values_with_multiple_bsn(self, m_bsn): "openforms.prefill.contrib.kvk.plugin.KVK_KVKNumberPrefill.get_prefill_values", return_value={"bezoekadres.postcode": "1111 AA"}, ) - def test_fetch_values_with_kvk_and_bsn(self, m_kvk, m_bsn): + def test_fetch_values_with_legal_entity_and_person(self, m_kvk, m_haal_centraal): components = [ { "key": "companyPostcode",