diff --git a/src/open_inwoner/accounts/tests/test_profile_views.py b/src/open_inwoner/accounts/tests/test_profile_views.py index 70edc94070..36e117e286 100644 --- a/src/open_inwoner/accounts/tests/test_profile_views.py +++ b/src/open_inwoner/accounts/tests/test_profile_views.py @@ -21,7 +21,7 @@ from open_inwoner.haalcentraal.tests.mixins import HaalCentraalMixin from open_inwoner.laposta.models import LapostaConfig from open_inwoner.laposta.tests.factories import LapostaListFactory, MemberFactory -from open_inwoner.openklant.models import OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig from open_inwoner.pdc.tests.factories import CategoryFactory from open_inwoner.plans.tests.factories import PlanFactory from open_inwoner.qmatic.tests.data import QmaticMockData @@ -598,7 +598,7 @@ def test_eherkenning_user_updates_klant_api(self, m): m, use_rsin=use_rsin_for_innNnpId_query_parameter ) - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.use_rsin_for_innNnpId_query_parameter = ( use_rsin_for_innNnpId_query_parameter ) diff --git a/src/open_inwoner/accounts/views/auth.py b/src/open_inwoner/accounts/views/auth.py index c4c407046d..7b61a261cb 100644 --- a/src/open_inwoner/accounts/views/auth.py +++ b/src/open_inwoner/accounts/views/auth.py @@ -23,7 +23,7 @@ from eherkenning.mock.views.eherkenning import ( eHerkenningAssertionConsumerServiceMockView, ) -from open_inwoner.openklant.models import OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig from open_inwoner.openzaak.models import OpenZaakConfig from open_inwoner.utils.views import LogMixin @@ -137,13 +137,13 @@ def get(self, request): response = super().get(request) openzaak_config = OpenZaakConfig.get_solo() - openklant_config = OpenKlantConfig.get_solo() + klant_config = ESuiteKlantConfig.get_solo() if ( hasattr(request.user, "rsin") and not request.user.rsin and ( openzaak_config.fetch_eherkenning_zaken_with_rsin - or openklant_config.use_rsin_for_innNnpId_query_parameter + or klant_config.use_rsin_for_innNnpId_query_parameter ) ): auth.logout(request) diff --git a/src/open_inwoner/accounts/views/mixins.py b/src/open_inwoner/accounts/views/mixins.py index 0dd8c4243e..4a386eb195 100644 --- a/src/open_inwoner/accounts/views/mixins.py +++ b/src/open_inwoner/accounts/views/mixins.py @@ -2,7 +2,7 @@ from django.core.exceptions import ImproperlyConfigured -from open_inwoner.openklant.models import OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig from open_inwoner.openklant.services import eSuiteKlantenService logger = logging.getLogger(__name__) @@ -14,7 +14,7 @@ def patch_klant(self, update_data: dict): return try: - service = eSuiteKlantenService(config=OpenKlantConfig.get_solo()) + service = eSuiteKlantenService(config=ESuiteKlantConfig.get_solo()) except ImproperlyConfigured: logger.error("Error building KlantenService") return diff --git a/src/open_inwoner/cms/cases/tests/test_contactform.py b/src/open_inwoner/cms/cases/tests/test_contactform.py index 70fa83394f..9c2db28601 100644 --- a/src/open_inwoner/cms/cases/tests/test_contactform.py +++ b/src/open_inwoner/cms/cases/tests/test_contactform.py @@ -20,7 +20,7 @@ eHerkenningUserFactory, ) from open_inwoner.openklant.constants import Status -from open_inwoner.openklant.models import OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig from open_inwoner.openklant.services import eSuiteVragenService from open_inwoner.openklant.tests.data import CONTACTMOMENTEN_ROOT, KLANTEN_ROOT from open_inwoner.openzaak.models import CatalogusConfig, OpenZaakConfig @@ -82,21 +82,21 @@ def setUp(self): ) self.oz_config.save() - # openklant config - self.ok_config = OpenKlantConfig.get_solo() - self.ok_config.send_email_confirmation = True - self.ok_config.register_contact_moment = True - self.ok_config.register_bronorganisatie_rsin = "123456788" - self.ok_config.register_type = "Melding" - self.ok_config.register_employee_id = "FooVonBar" - self.ok_config.register_channel = "the-designated-channel" - self.ok_config.klanten_service = ServiceFactory( + # klant config + self.klant_config = ESuiteKlantConfig.get_solo() + self.klant_config.send_email_confirmation = True + self.klant_config.register_contact_moment = True + self.klant_config.register_bronorganisatie_rsin = "123456788" + self.klant_config.register_type = "Melding" + self.klant_config.register_employee_id = "FooVonBar" + self.klant_config.register_channel = "the-designated-channel" + self.klant_config.klanten_service = ServiceFactory( api_root=KLANTEN_ROOT, api_type=APITypes.kc ) - self.ok_config.contactmomenten_service = ServiceFactory( + self.klant_config.contactmomenten_service = ServiceFactory( api_root=CONTACTMOMENTEN_ROOT, api_type=APITypes.cmc ) - self.ok_config.save() + self.klant_config.save() self.zaak = generate_oas_component_cached( "zrc", @@ -371,7 +371,7 @@ def test_form_is_shown_if_open_klant_api_configured( self._setUpMocks(m) self._setUpExtraMocks(m) - self.assertTrue(self.ok_config.has_api_configuration()) + self.assertTrue(self.klant_config.has_api_configuration()) response = self.app.get(self.case_detail_url, user=self.user) contact_form = response.pyquery("#contact-form") @@ -387,12 +387,12 @@ def test_form_is_shown_if_open_klant_email_configured( self._setUpMocks(m) self._setUpExtraMocks(m) - self.ok_config.register_email = "example@example.com" - self.ok_config.register_contact_moment = False - self.ok_config.save() + self.klant_config.register_email = "example@example.com" + self.klant_config.register_contact_moment = False + self.klant_config.save() - self.assertFalse(self.ok_config.has_api_configuration()) - self.assertTrue(self.ok_config.has_register()) + self.assertFalse(self.klant_config.has_api_configuration()) + self.assertTrue(self.klant_config.has_register()) response = self.app.get(self.case_detail_url, user=self.user) contact_form = response.pyquery("#contact-form") @@ -408,11 +408,11 @@ def test_form_is_shown_if_open_klant_email_and_api_configured( self._setUpMocks(m) self._setUpExtraMocks(m) - self.ok_config.register_email = "example@example.com" - self.ok_config.save() + self.klant_config.register_email = "example@example.com" + self.klant_config.save() - self.assertTrue(self.ok_config.has_api_configuration()) - self.assertTrue(self.ok_config.has_register()) + self.assertTrue(self.klant_config.has_api_configuration()) + self.assertTrue(self.klant_config.has_register()) response = self.app.get(self.case_detail_url, user=self.user) contact_form = response.pyquery("#contact-form") @@ -428,15 +428,15 @@ def test_no_form_shown_if_open_klant_not_configured( self._setUpMocks(m) # reset - self.ok_config.klanten_service = None - self.ok_config.contactmomenten_service = None - self.ok_config.register_email = "" - self.ok_config.register_contact_moment = False - self.ok_config.register_bronorganisatie_rsin = "" - self.ok_config.register_type = "" - self.ok_config.register_employee_id = "" - self.ok_config.save() - self.assertFalse(self.ok_config.has_api_configuration()) + self.klant_config.klanten_service = None + self.klant_config.contactmomenten_service = None + self.klant_config.register_email = "" + self.klant_config.register_contact_moment = False + self.klant_config.register_bronorganisatie_rsin = "" + self.klant_config.register_type = "" + self.klant_config.register_employee_id = "" + self.klant_config.save() + self.assertFalse(self.klant_config.has_api_configuration()) response = self.app.get(self.case_detail_url, user=self.user) contact_form = response.pyquery("#contact-form") @@ -529,7 +529,7 @@ def test_form_success_missing_medewerker( self._setUpMocks(m) self._setUpExtraMocks(m) - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() # empty id should be excluded from contactmoment_create_data config.register_employee_id = "" config.save() @@ -598,7 +598,7 @@ def test_form_success_with_api_eherkenning_user( kvk="12345678", rsin="000000000" ) - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.use_rsin_for_innNnpId_query_parameter = ( use_rsin_for_innNnpId_query_parameter ) @@ -665,9 +665,9 @@ def test_form_success_with_email(self, m, mock_contactmoment, mock_send_confirm) self._setUpMocks(m) self._setUpExtraMocks(m) - self.ok_config.register_email = "example@example.com" - self.ok_config.register_contact_moment = False - self.ok_config.save() + self.klant_config.register_email = "example@example.com" + self.klant_config.register_contact_moment = False + self.klant_config.save() response = self.app.get(self.case_detail_url, user=self.user) form = response.forms["contact-form"] @@ -708,8 +708,8 @@ def test_form_success_with_both_email_and_api( self._setUpMocks(m) self._setUpExtraMocks(m) - self.ok_config.register_email = "example@example.com" - self.ok_config.save() + self.klant_config.register_email = "example@example.com" + self.klant_config.save() response = self.app.get(self.case_detail_url, user=self.user) form = response.forms["contact-form"] @@ -746,7 +746,7 @@ def test_send_email_confirmation_is_configurable__send_enabled( self._setUpMocks(m) self._setUpExtraMocks(m) - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.send_email_confirmation = True config.save() @@ -766,7 +766,7 @@ def test_send_email_confirmation_is_configurable__send_disabled( self._setUpMocks(m) self._setUpExtraMocks(m) - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.send_email_confirmation = False config.save() diff --git a/src/open_inwoner/cms/cases/tests/test_htmx.py b/src/open_inwoner/cms/cases/tests/test_htmx.py index ef0e03dbb5..876b6a0fb4 100644 --- a/src/open_inwoner/cms/cases/tests/test_htmx.py +++ b/src/open_inwoner/cms/cases/tests/test_htmx.py @@ -18,7 +18,7 @@ from open_inwoner.cms.tests import cms_tools from open_inwoner.configurations.models import SiteConfiguration from open_inwoner.openklant.constants import Status -from open_inwoner.openklant.models import OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig from open_inwoner.openklant.services import eSuiteVragenService from open_inwoner.openklant.tests.data import CONTACTMOMENTEN_ROOT, KLANTEN_ROOT from open_inwoner.openzaak.models import OpenZaakConfig @@ -88,19 +88,19 @@ def setUp(self) -> None: ) self.oz_config.save() - # openklant config - self.ok_config = OpenKlantConfig.get_solo() - self.ok_config.register_contact_moment = True - self.ok_config.register_bronorganisatie_rsin = "123456788" - self.ok_config.register_type = "Melding" - self.ok_config.register_employee_id = "FooVonBar" - self.ok_config.klanten_service = ServiceFactory( + # klant config + self.klant_config = ESuiteKlantConfig.get_solo() + self.klant_config.register_contact_moment = True + self.klant_config.register_bronorganisatie_rsin = "123456788" + self.klant_config.register_type = "Melding" + self.klant_config.register_employee_id = "FooVonBar" + self.klant_config.klanten_service = ServiceFactory( api_root=KLANTEN_ROOT, api_type=APITypes.kc ) - self.ok_config.contactmomenten_service = ServiceFactory( + self.klant_config.contactmomenten_service = ServiceFactory( api_root=CONTACTMOMENTEN_ROOT, api_type=APITypes.cmc ) - self.ok_config.save() + self.klant_config.save() self.zaak = generate_oas_component_cached( "zrc", diff --git a/src/open_inwoner/cms/cases/views/status.py b/src/open_inwoner/cms/cases/views/status.py index 9cacc7d884..fb6ecc96db 100644 --- a/src/open_inwoner/cms/cases/views/status.py +++ b/src/open_inwoner/cms/cases/views/status.py @@ -28,7 +28,7 @@ from open_inwoner.accounts.models import User from open_inwoner.mail.service import send_contact_confirmation_mail from open_inwoner.openklant.constants import KlantenServiceType -from open_inwoner.openklant.models import OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig from open_inwoner.openklant.services import ( OpenKlant2Service, Question, @@ -509,7 +509,7 @@ def get_upload_info_context(self, case: Zaak): if not case: return {} - open_klant_config = OpenKlantConfig.get_solo() + open_klant_config = ESuiteKlantConfig.get_solo() case_type_config_description = "" case_type_document_upload_description = "" @@ -905,7 +905,7 @@ def post(self, request, *args, **kwargs): form = self.get_form() if form.is_valid(): - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() email_success = False api_success = False @@ -986,7 +986,7 @@ def register_by_email(self, form, recipient_email): ) return False - def register_by_api(self, form, config: OpenKlantConfig): + def register_by_api(self, form, config: ESuiteKlantConfig): assert config.has_api_configuration() try: @@ -994,9 +994,8 @@ def register_by_api(self, form, config: OpenKlantConfig): except ObjectDoesNotExist: ztc = None - # TODO - openklant_config = OpenKlantConfig.get_solo() - service = eSuiteKlantenService(config=openklant_config) + esuite_klant_config = ESuiteKlantConfig.get_solo() + service = eSuiteKlantenService(config=esuite_klant_config) if klanten_client := service.client: klant = service.retrieve_klant(**get_fetch_parameters(self.request)) @@ -1046,7 +1045,7 @@ def register_by_api(self, form, config: OpenKlantConfig): data["onderwerp"] = ztc.contact_subject_code try: - service = eSuiteVragenService(config=openklant_config) + service = eSuiteVragenService(config=esuite_klant_config) except RuntimeError: logger.error("Failed to build eSuiteVragenService") return diff --git a/src/open_inwoner/cms/footer/cms_plugins.py b/src/open_inwoner/cms/footer/cms_plugins.py index c8f67a7ec9..a03bd78609 100644 --- a/src/open_inwoner/cms/footer/cms_plugins.py +++ b/src/open_inwoner/cms/footer/cms_plugins.py @@ -4,7 +4,7 @@ from cms.plugin_pool import plugin_pool from open_inwoner.configurations.models import SiteConfiguration -from open_inwoner.openklant.models import OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig @plugin_pool.register_plugin @@ -17,7 +17,7 @@ class FooterPagesPlugin(CMSPluginBase): def render(self, context, instance, placeholder): # TODO move options to plugin model config = SiteConfiguration.get_solo() - ok_config = OpenKlantConfig.get_solo() + ok_config = ESuiteKlantConfig.get_solo() context["flatpages"] = config.get_ordered_flatpages context["has_form_configuration"] = ok_config.has_form_configuration() return context diff --git a/src/open_inwoner/cms/footer/tests/test_plugin.py b/src/open_inwoner/cms/footer/tests/test_plugin.py index a781f8b34b..021defbfe0 100644 --- a/src/open_inwoner/cms/footer/tests/test_plugin.py +++ b/src/open_inwoner/cms/footer/tests/test_plugin.py @@ -3,7 +3,7 @@ from open_inwoner.cms.footer.cms_plugins import FooterPagesPlugin from open_inwoner.cms.tests import cms_tools -from open_inwoner.openklant.models import OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig from open_inwoner.openklant.tests.factories import ContactFormSubjectFactory from open_inwoner.utils.test import ClearCachesMixin @@ -12,7 +12,7 @@ class ContactFormTestCase(ClearCachesMixin, TestCase): def setUp(self): super().setUp() # clear config - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.klanten_service = None config.contactmomenten_service = None config.register_email = "" @@ -25,7 +25,7 @@ def setUp(self): def test_no_form_link_shown_in_footer_if_not_has_configuration(self): # set nothing - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() self.assertFalse(config.has_form_configuration()) html, context = cms_tools.render_plugin(FooterPagesPlugin) @@ -33,7 +33,7 @@ def test_no_form_link_shown_in_footer_if_not_has_configuration(self): self.assertNotIn(_("Contact formulier"), html) def test_form_link_is_shown_in_footer_when_has_configuration(self): - ok_config = OpenKlantConfig.get_solo() + ok_config = ESuiteKlantConfig.get_solo() self.assertFalse(ok_config.has_form_configuration()) ContactFormSubjectFactory(config=ok_config) diff --git a/src/open_inwoner/conf/app/setup_configuration.py b/src/open_inwoner/conf/app/setup_configuration.py index a7e45ac861..0d075a0cb8 100644 --- a/src/open_inwoner/conf/app/setup_configuration.py +++ b/src/open_inwoner/conf/app/setup_configuration.py @@ -4,7 +4,7 @@ "mozilla_django_oidc_db.setup_configuration.steps.AdminOIDCConfigurationStep", "zgw_consumers.contrib.setup_configuration.steps.ServiceConfigurationStep", "open_inwoner.configurations.bootstrap.zgw.OpenZaakConfigurationStep", - "open_inwoner.configurations.bootstrap.openklant.OpenKlantConfigurationStep", + "open_inwoner.configurations.bootstrap.openklant.ESuiteKlantConfigurationStep", "open_inwoner.configurations.bootstrap.openklant.OpenKlant2ConfigurationStep", ] OIP_ORGANIZATION = config("OIP_ORGANIZATION", "") diff --git a/src/open_inwoner/conf/fixtures/django-admin-index.json b/src/open_inwoner/conf/fixtures/django-admin-index.json index 530aee5dd9..21e5ccbc0a 100644 --- a/src/open_inwoner/conf/fixtures/django-admin-index.json +++ b/src/open_inwoner/conf/fixtures/django-admin-index.json @@ -310,7 +310,7 @@ ], [ "openklant", - "openklantconfig" + "esuiteklantconfig" ], [ "openzaak", diff --git a/src/open_inwoner/configurations/bootstrap/openklant.py b/src/open_inwoner/configurations/bootstrap/openklant.py index a44986bfe4..ea8eb8f9ab 100644 --- a/src/open_inwoner/configurations/bootstrap/openklant.py +++ b/src/open_inwoner/configurations/bootstrap/openklant.py @@ -9,7 +9,7 @@ from zgw_consumers.models import Service from open_inwoner.configurations.bootstrap.utils import get_service -from open_inwoner.openklant.models import OpenKlant2Config, OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig, OpenKlant2Config class OpenKlant2Configuration(ConfigurationModel): @@ -32,7 +32,7 @@ class KlantenApiConfigurationModel(ConfigurationModel): klanten_service_identifier: str contactmomenten_service_identifier: str exclude_contactmoment_kanalen: list[str] | None = DjangoModelRef( - OpenKlantConfig, + ESuiteKlantConfig, "exclude_contactmoment_kanalen", default=None, ) @@ -40,7 +40,7 @@ class KlantenApiConfigurationModel(ConfigurationModel): class Meta: django_model_refs = { - OpenKlantConfig: ( + ESuiteKlantConfig: ( "register_email", "register_contact_moment", "register_bronorganisatie_rsin", @@ -53,7 +53,7 @@ class Meta: } -class OpenKlantConfigurationStep(BaseConfigurationStep[KlantenApiConfigurationModel]): +class ESuiteKlantConfigurationStep(BaseConfigurationStep[KlantenApiConfigurationModel]): """ Configure the KIC settings and set any feature flags or other options if specified """ @@ -64,7 +64,7 @@ class OpenKlantConfigurationStep(BaseConfigurationStep[KlantenApiConfigurationMo config_model = KlantenApiConfigurationModel def execute(self, model: KlantenApiConfigurationModel): - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() try: kc = get_service(model.klanten_service_identifier) @@ -132,10 +132,7 @@ def execute(self, model: OpenKlant2Configuration): "service": service } - try: - config = OpenKlant2Config.objects.get() - except OpenKlant2Config.DoesNotExist: - config = OpenKlant2Config() + config = OpenKlant2Config.get_solo() for key, val in create_or_update_kwargs.items(): setattr(config, key, val) diff --git a/src/open_inwoner/configurations/tests/bootstrap/files/openklant_config_step_full.yaml b/src/open_inwoner/configurations/tests/bootstrap/files/esuiteklant_config_step_full.yaml similarity index 100% rename from src/open_inwoner/configurations/tests/bootstrap/files/openklant_config_step_full.yaml rename to src/open_inwoner/configurations/tests/bootstrap/files/esuiteklant_config_step_full.yaml diff --git a/src/open_inwoner/configurations/tests/bootstrap/test_setup_openklant_config.py b/src/open_inwoner/configurations/tests/bootstrap/test_setup_openklant_config.py index 6f142692f4..5cf64b619e 100644 --- a/src/open_inwoner/configurations/tests/bootstrap/test_setup_openklant_config.py +++ b/src/open_inwoner/configurations/tests/bootstrap/test_setup_openklant_config.py @@ -6,23 +6,23 @@ from django_setup_configuration.test_utils import execute_single_step from zgw_consumers.constants import APITypes -from open_inwoner.openklant.models import OpenKlant2Config, OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig, OpenKlant2Config from open_inwoner.openzaak.tests.factories import ServiceFactory from ...bootstrap.openklant import ( + ESuiteKlantConfigurationStep, OpenKlant2ConfigurationStep, - OpenKlantConfigurationStep, ) KLANTEN_SERVICE_API_ROOT = "https://openklant.local/klanten/api/v1/" CONTACTMOMENTEN_SERVICE_API_ROOT = "https://openklant.local/contactmomenten/api/v1/" BASE_DIR = Path(__file__).parent / "files" -OPENKLANT_CONFIG_STEP_FULL_YAML = str(BASE_DIR / "openklant_config_step_full.yaml") +ESUITEKLANT_CONFIG_STEP_FULL_YAML = str(BASE_DIR / "esuiteklant_config_step_full.yaml") OPENKLANT2_CONFIG_STEP_FULL_YAML = str(BASE_DIR / "openklant2_config_step_full.yaml") -class OpenKlantConfigurationStepTestCase(TestCase): +class ESuiteKlantConfigurationStepTestCase(TestCase): def test_configure(self): kc = ServiceFactory( slug="klanten-service", @@ -35,10 +35,10 @@ def test_configure(self): api_type=APITypes.cmc, ) execute_single_step( - OpenKlantConfigurationStep, yaml_source=OPENKLANT_CONFIG_STEP_FULL_YAML + ESuiteKlantConfigurationStep, yaml_source=ESUITEKLANT_CONFIG_STEP_FULL_YAML ) - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() self.assertEqual(config.klanten_service, kc) self.assertEqual(config.contactmomenten_service, cmc) @@ -65,7 +65,8 @@ def test_configure_with_bad_service_identifiers(self): with self.assertRaises(ConfigurationRunFailed) as exc: execute_single_step( - OpenKlantConfigurationStep, yaml_source=OPENKLANT_CONFIG_STEP_FULL_YAML + ESuiteKlantConfigurationStep, + yaml_source=ESUITEKLANT_CONFIG_STEP_FULL_YAML, ) self.assertEqual( @@ -91,7 +92,8 @@ def test_configure_with_bad_api_type_for_klanten_service(self): with self.assertRaises(ConfigurationRunFailed) as exc: execute_single_step( - OpenKlantConfigurationStep, yaml_source=OPENKLANT_CONFIG_STEP_FULL_YAML + ESuiteKlantConfigurationStep, + yaml_source=ESUITEKLANT_CONFIG_STEP_FULL_YAML, ) self.assertEqual( @@ -116,7 +118,8 @@ def test_configure_with_bad_api_type_for_contactmomenten_service(self): with self.assertRaises(ConfigurationRunFailed) as exc: execute_single_step( - OpenKlantConfigurationStep, yaml_source=OPENKLANT_CONFIG_STEP_FULL_YAML + ESuiteKlantConfigurationStep, + yaml_source=ESUITEKLANT_CONFIG_STEP_FULL_YAML, ) self.assertEqual( @@ -141,7 +144,7 @@ def test_idempotent_configure(self): ) def assert_values(): - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() self.assertEqual(config.klanten_service, kc) self.assertEqual(config.contactmomenten_service, cmc) @@ -155,12 +158,12 @@ def assert_values(): self.assertEqual(config.use_rsin_for_innNnpId_query_parameter, True) execute_single_step( - OpenKlantConfigurationStep, yaml_source=OPENKLANT_CONFIG_STEP_FULL_YAML + ESuiteKlantConfigurationStep, yaml_source=ESUITEKLANT_CONFIG_STEP_FULL_YAML ) assert_values() - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.register_email = "not-admin@oip.org" config.register_contact_moment = False config.register_bronorganisatie_rsin = "800000009" @@ -171,7 +174,7 @@ def assert_values(): config.save() execute_single_step( - OpenKlantConfigurationStep, yaml_source=OPENKLANT_CONFIG_STEP_FULL_YAML + ESuiteKlantConfigurationStep, yaml_source=ESUITEKLANT_CONFIG_STEP_FULL_YAML ) assert_values() @@ -189,7 +192,7 @@ def test_configure(self): OpenKlant2ConfigurationStep, yaml_source=OPENKLANT2_CONFIG_STEP_FULL_YAML ) - config = OpenKlant2Config.objects.get() + config = OpenKlant2Config.get_solo() self.assertEqual(config.service, kc) self.assertEqual(config.mijn_vragen_kanaal, "formulier") diff --git a/src/open_inwoner/openklant/admin.py b/src/open_inwoner/openklant/admin.py index bca5941f29..7fcfd2c918 100644 --- a/src/open_inwoner/openklant/admin.py +++ b/src/open_inwoner/openklant/admin.py @@ -5,7 +5,13 @@ from ordered_model.admin import OrderedInlineModelAdminMixin, OrderedTabularInline from solo.admin import SingletonModelAdmin -from .models import ContactFormSubject, KlantContactMomentAnswer, OpenKlantConfig +from .models import ( + ContactFormSubject, + ESuiteKlantConfig, + KlantContactMomentAnswer, + KlantenSysteemConfig, + OpenKlant2Config, +) class ContactFormSubjectForm(forms.ModelForm): @@ -32,9 +38,9 @@ class ContactFormSubjectInlineAdmin(OrderedTabularInline): extra = 0 -class OpenKlantConfigAdminForm(forms.ModelForm): +class ESuiteKlantConfigAdminForm(forms.ModelForm): class Meta: - model = OpenKlantConfig + model = ESuiteKlantConfig fields = "__all__" def clean(self, *args, **kwargs): @@ -44,14 +50,14 @@ def clean(self, *args, **kwargs): msg = _( "Voor registratie in de Klanten en Contactmomenten API is dit veld vereist." ) - for field_name in OpenKlantConfig.register_api_required_fields: + for field_name in ESuiteKlantConfig.register_api_required_fields: if not cleaned_data[field_name]: self.add_error(field_name, msg) -@admin.register(OpenKlantConfig) -class OpenKlantConfigAdmin(OrderedInlineModelAdminMixin, SingletonModelAdmin): - form = OpenKlantConfigAdminForm +@admin.register(ESuiteKlantConfig) +class ESuiteKlantConfigAdmin(OrderedInlineModelAdminMixin, SingletonModelAdmin): + form = ESuiteKlantConfigAdminForm inlines = [ ContactFormSubjectInlineAdmin, ] @@ -108,3 +114,50 @@ class KlantContactMomentAnswerAdmin(admin.ModelAdmin): ] list_filter = ["is_seen"] list_display = ["user", "contactmoment_url", "is_seen"] + + +# +# OpenKlant2 +# + + +class OpenKlant2ConfigAdminForm(forms.ModelForm): + class Meta: + model = OpenKlant2Config + fields = "__all__" + + +@admin.register(OpenKlant2Config) +class OpenKlant2ConfigAdmin(SingletonModelAdmin): + model = OpenKlant2Config + form = OpenKlant2ConfigAdminForm + fieldsets = [ + ( + _("API configuration"), + { + "fields": [ + "service", + ] + }, + ), + ( + _("Vragen"), + { + "fields": [ + "mijn_vragen_kanaal", + "mijn_vragen_organisatie_naam", + "mijn_vragen_actor", + "interne_taak_gevraagde_handeling", + "interne_taak_toelichting", + ] + }, + ), + ] + + +@admin.register(KlantenSysteemConfig) +class KlantenSysteemConfigAdmin(SingletonModelAdmin): + change_form_template = "admin/openklant/klantensysteemconfig/change_form.html" + + class Meta: + model = KlantenSysteemConfig diff --git a/src/open_inwoner/openklant/clients.py b/src/open_inwoner/openklant/clients.py index 96b6459ada..4449401ba6 100644 --- a/src/open_inwoner/openklant/clients.py +++ b/src/open_inwoner/openklant/clients.py @@ -18,7 +18,7 @@ KlantCreateData, ObjectContactMoment, ) -from .models import OpenKlantConfig +from .models import ESuiteKlantConfig logger = logging.getLogger(__name__) @@ -328,7 +328,7 @@ def retrieve_objectcontactmoment( def _build_open_klant_client(type_) -> APIClient | None: - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() services_to_client_mapping = { "klanten": KlantenClient, "contactmomenten": ContactmomentenClient, diff --git a/src/open_inwoner/openklant/forms.py b/src/open_inwoner/openklant/forms.py index f716b96c70..f04cb47f30 100644 --- a/src/open_inwoner/openklant/forms.py +++ b/src/open_inwoner/openklant/forms.py @@ -2,7 +2,7 @@ from django.utils.translation import gettext_lazy as _ from open_inwoner.accounts.models import User -from open_inwoner.openklant.models import ContactFormSubject, OpenKlantConfig +from open_inwoner.openklant.models import ContactFormSubject, ESuiteKlantConfig from open_inwoner.openklant.views.utils import generate_question_answer_pair from open_inwoner.utils.validators import DutchPhoneNumberValidator @@ -57,7 +57,7 @@ def __init__(self, user, request_session, *args, **kwargs): self.user = user self.request_session = request_session - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() self.fields["subject"].queryset = config.contactformsubject_set.all() if self.user.is_authenticated: diff --git a/src/open_inwoner/openklant/migrations/0016_klantensysteemconfig.py b/src/open_inwoner/openklant/migrations/0016_klantensysteemconfig.py new file mode 100644 index 0000000000..8b3b472d4a --- /dev/null +++ b/src/open_inwoner/openklant/migrations/0016_klantensysteemconfig.py @@ -0,0 +1,38 @@ +# Generated by Django 4.2.16 on 2025-01-07 11:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("openklant", "0015_openklant2config"), + ] + + operations = [ + migrations.CreateModel( + name="KlantenSysteemConfig", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "primary_backend", + models.CharField( + choices=[("esuite", "ESUITE"), ("openklant2", "OPENKLANT2")], + max_length=10, + help_text="Choose the primary backend for retrieving klanten data. Changes to klanten data will be saved to both backends (if configured).", + ), + ), + ], + options={ + "verbose_name": "Configuratie Klanten Systeem", + }, + ), + ] diff --git a/src/open_inwoner/openklant/migrations/0017_alter_openklant2config_service.py b/src/open_inwoner/openklant/migrations/0017_alter_openklant2config_service.py new file mode 100644 index 0000000000..419e8346c0 --- /dev/null +++ b/src/open_inwoner/openklant/migrations/0017_alter_openklant2config_service.py @@ -0,0 +1,26 @@ +# Generated by Django 4.2.16 on 2025-01-08 14:37 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("zgw_consumers", "0022_set_default_service_slug"), + ("openklant", "0016_klantensysteemconfig"), + ] + + operations = [ + migrations.AlterField( + model_name="openklant2config", + name="service", + field=models.OneToOneField( + null=True, + on_delete=django.db.models.deletion.PROTECT, + related_name="+", + to="zgw_consumers.service", + verbose_name="Klanten API", + ), + ), + ] diff --git a/src/open_inwoner/openklant/migrations/0018_rename_openklantconfig_esuiteklantconfig_and_more.py b/src/open_inwoner/openklant/migrations/0018_rename_openklantconfig_esuiteklantconfig_and_more.py new file mode 100644 index 0000000000..6b10f4cc33 --- /dev/null +++ b/src/open_inwoner/openklant/migrations/0018_rename_openklantconfig_esuiteklantconfig_and_more.py @@ -0,0 +1,34 @@ +# Generated by Django 4.2.16 on 2025-01-09 10:52 + +from django.db import migrations, models + +import open_inwoner.openklant.models + + +class Migration(migrations.Migration): + + dependencies = [ + ("zgw_consumers", "0022_set_default_service_slug"), + ("openklant", "0017_alter_openklant2config_service"), + ] + + operations = [ + migrations.RenameModel( + old_name="OpenKlantConfig", + new_name="ESuiteKlantConfig", + ), + migrations.AlterField( + model_name="klantensysteemconfig", + name="primary_backend", + field=models.CharField( + choices=[("esuite", "ESUITE"), ("openklant2", "OPENKLANT2")], + help_text="Choose the primary backend for retrieving klanten data. Changes to klanten data will be saved to both backends (if configured).", + max_length=10, + validators=[open_inwoner.openklant.models.validate_primary_backend], + ), + ), + migrations.AlterModelOptions( + name="esuiteklantconfig", + options={"verbose_name": "eSuite Klant configuration"}, + ), + ] diff --git a/src/open_inwoner/openklant/models.py b/src/open_inwoner/openklant/models.py index 2f20e55502..9c0d4f53cf 100644 --- a/src/open_inwoner/openklant/models.py +++ b/src/open_inwoner/openklant/models.py @@ -1,3 +1,4 @@ +from django.core.exceptions import ValidationError from django.db import models from django.utils.translation import gettext_lazy as _ @@ -8,16 +9,18 @@ from open_inwoner.utils.validators import validate_array_contents_non_empty +from .constants import KlantenServiceType -class OpenKlantConfigManager(models.Manager): + +class ESuiteKlantConfigManager(models.Manager): def get_queryset(self): qs = super().get_queryset() return qs.select_related("klanten_service", "contactmomenten_service") -class OpenKlantConfig(SingletonModel): +class ESuiteKlantConfig(SingletonModel): """ - Global configuration and defaults for Klant & Contactmomenten APIs + Configuration and defaults for eSuite Klant & Contactmomenten APIs """ klanten_service = models.OneToOneField( @@ -117,10 +120,10 @@ class OpenKlantConfig(SingletonModel): "register_type", ) - objects = OpenKlantConfigManager() + objects = ESuiteKlantConfigManager() class Meta: - verbose_name = _("Open Klant configuration") + verbose_name = _("eSuite Klant configuration") def has_register(self) -> bool: return self.register_email or self.has_api_configuration() @@ -132,51 +135,6 @@ def has_api_configuration(self): return all(getattr(self, f, "") for f in self.register_api_required_fields) -class OpenKlant2ConfigManager(models.Manager): - def get_queryset(self): - qs = super().get_queryset() - return qs.select_related("service") - - -class OpenKlant2Config(models.Model): - service = models.OneToOneField( - "zgw_consumers.Service", - verbose_name=_("Klanten API"), - on_delete=models.PROTECT, - related_name="+", - ) - - # Vragen - mijn_vragen_kanaal = models.CharField( - verbose_name=_("Mijn vragen kanaal"), - default="", - blank=True, - ) - mijn_vragen_organisatie_naam = models.CharField( - verbose_name=_("Mijn vragen organisatie naam"), - default="", - blank=True, - ) - mijn_vragen_actor = models.CharField( - verbose_name=_("Mijn vragen actor"), - default="", - blank=True, - ) - interne_taak_gevraagde_handeling = models.CharField( - verbose_name=_("Interne taak gevraagde handeling"), - default="", - blank=True, - ) - interne_taak_toelichting = models.CharField( - verbose_name=_("Interne taak toelichting"), - default="", - blank=True, - ) - - class Meta: - verbose_name = _("OpenKlant2 configuration") - - class ContactFormSubject(OrderedModel): subject = models.CharField( verbose_name=_("Onderwerp"), @@ -187,9 +145,8 @@ class ContactFormSubject(OrderedModel): max_length=255, blank=True, ) - # FK for easy inline admins config = models.ForeignKey( - OpenKlantConfig, + "ESuiteKlantConfig", on_delete=models.CASCADE, ) @@ -229,3 +186,84 @@ class Meta: verbose_name = _("KlantContactMoment") verbose_name_plural = _("KlantContactMomenten") unique_together = [["user", "contactmoment_url"]] + + +class OpenKlant2Config(SingletonModel): + service = models.OneToOneField( + "zgw_consumers.Service", + verbose_name=_("Klanten API"), + on_delete=models.PROTECT, + null=True, + related_name="+", + ) + + # Vragen + mijn_vragen_kanaal = models.CharField( + verbose_name=_("Mijn vragen kanaal"), + default="", + blank=True, + ) + mijn_vragen_organisatie_naam = models.CharField( + verbose_name=_("Mijn vragen organisatie naam"), + default="", + blank=True, + ) + mijn_vragen_actor = models.CharField( + verbose_name=_("Mijn vragen actor"), + default="", + blank=True, + ) + interne_taak_gevraagde_handeling = models.CharField( + verbose_name=_("Interne taak gevraagde handeling"), + default="", + blank=True, + ) + interne_taak_toelichting = models.CharField( + verbose_name=_("Interne taak toelichting"), + default="", + blank=True, + ) + + class Meta: + verbose_name = _("OpenKlant2 configuration") + + +def validate_primary_backend(value): + if value == KlantenServiceType.OPENKLANT2.value: + config = OpenKlant2Config.get_solo() + if not config.service: + raise ValidationError( + "OpenKlant2 must be configured with a Klanten API service before it can be selected " + "as primary backend" + ) + return + + config = ESuiteKlantConfig.get_solo() + if not config.klanten_service: + raise ValidationError( + "The Esuite klant system must be configured with a Klanten API service before it can be selected " + "as primary backend" + ) + if not config.contactmomenten_service: + raise ValidationError( + "The Esuite klant system must be configured with a Contactmomenten API service service before " + "it can be selected as primary backend" + ) + + +class KlantenSysteemConfig(SingletonModel): + primary_backend = models.CharField( + max_length=10, + choices=[(service.value, service.name) for service in KlantenServiceType], + help_text=_( + "Choose the primary backend for retrieving klanten data. " + "Changes to klanten data will be saved to both backends (if configured)." + ), + validators=[validate_primary_backend], + ) + + class Meta: + verbose_name = _("Configuratie Klanten Systeem") + + def __str__(self): + return "Configuratie Klanten Systeem" diff --git a/src/open_inwoner/openklant/services.py b/src/open_inwoner/openklant/services.py index bdd198b1c7..d43caad76c 100644 --- a/src/open_inwoner/openklant/services.py +++ b/src/open_inwoner/openklant/services.py @@ -37,9 +37,9 @@ from open_inwoner.openklant.constants import KlantenServiceType, Status from open_inwoner.openklant.models import ( ContactFormSubject, + ESuiteKlantConfig, KlantContactMomentAnswer, OpenKlant2Config, - OpenKlantConfig, ) from open_inwoner.openklant.wrap import ( contactmoment_has_new_answer, @@ -101,7 +101,7 @@ class Question(TypedDict): class KlantenService(Protocol): - config: OpenKlantConfig | OpenKlant2Config + config: ESuiteKlantConfig | OpenKlant2Config service_config: ServiceConfig client: APIClient @@ -120,7 +120,7 @@ def get_fetch_parameters( return {"user_bsn": user.bsn} elif user.kvk: kvk_or_rsin = user.kvk - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() if config.use_rsin_for_innNnpId_query_parameter: kvk_or_rsin = user.rsin @@ -138,10 +138,10 @@ def get_fetch_parameters( class eSuiteKlantenService(KlantenService): - config: OpenKlantConfig + config: ESuiteKlantConfig - def __init__(self, config: OpenKlantConfig | None = None): - self.config = config or OpenKlantConfig.get_solo() + def __init__(self, config: ESuiteKlantConfig | None = None): + self.config = config or ESuiteKlantConfig.get_solo() if not self.config: raise ImproperlyConfigured( "eSuiteKlantenService instance needs a configuration" @@ -355,10 +355,10 @@ def partial_update_klant(self, klant: Klant, update_data) -> Klant | None: class eSuiteVragenService(KlantenService): - config: OpenKlantConfig + config: ESuiteKlantConfig - def __init__(self, config: OpenKlantConfig | None = None): - self.config = config or OpenKlantConfig.get_solo() + def __init__(self, config: ESuiteKlantConfig | None = None): + self.config = config or ESuiteKlantConfig.get_solo() if not self.config: raise RuntimeError("eSuiteVragenService instance needs a configuration") @@ -651,7 +651,7 @@ def list_questions( ) -> Iterable[Question]: kcms = self.fetch_klantcontactmomenten(**fetch_params) - klant_config = OpenKlantConfig.get_solo() + klant_config = ESuiteKlantConfig.get_solo() if exclude_range := klant_config.exclude_contactmoment_kanalen: kcms = [ item @@ -823,13 +823,7 @@ class OpenKlant2Service(KlantenService): client: OpenKlant2Client def __init__(self, config: OpenKlant2Config | None = None): - try: - self.config = config or OpenKlant2Config.objects.get() - except OpenKlant2Config.DoesNotExist: - raise ImproperlyConfigured("OpenKlant2Config not configured") - except OpenKlant2Config.MultipleObjectsReturned: - raise ImproperlyConfigured("Found multiple instances of OpenKlant2Config") - + self.config = config or OpenKlant2Config.get_solo() self.client = OpenKlant2Client( base_url=self.config.service.api_root, request_kwargs={ diff --git a/src/open_inwoner/openklant/tests/data.py b/src/open_inwoner/openklant/tests/data.py index 6fad7f6308..299b55d0d2 100644 --- a/src/open_inwoner/openklant/tests/data.py +++ b/src/open_inwoner/openklant/tests/data.py @@ -6,7 +6,7 @@ eHerkenningUserFactory, ) from open_inwoner.openklant.constants import Status -from open_inwoner.openklant.models import OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig from open_inwoner.openzaak.tests.factories import ( ServiceFactory, ZGWApiGroupConfigFactory, @@ -23,7 +23,7 @@ class MockAPIData: @classmethod def setUpServices(cls): - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.klanten_service = ServiceFactory( api_root=KLANTEN_ROOT, api_type=APITypes.kc ) diff --git a/src/open_inwoner/openklant/tests/test_contactform.py b/src/open_inwoner/openklant/tests/test_contactform.py index 477fd87eba..68a4d8b74e 100644 --- a/src/open_inwoner/openklant/tests/test_contactform.py +++ b/src/open_inwoner/openklant/tests/test_contactform.py @@ -11,7 +11,7 @@ from open_inwoner.accounts.tests.factories import UserFactory from open_inwoner.openklant.api_models import KlantContactRol -from open_inwoner.openklant.models import OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig from open_inwoner.openklant.tests.data import MockAPICreateData from open_inwoner.openklant.tests.factories import ContactFormSubjectFactory from open_inwoner.openklant.views.contactform import ContactFormView @@ -51,7 +51,7 @@ def setUpTestData(cls): def setUp(self): super().setUp() # clear config - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.klanten_service = None config.contactmomenten_service = None config.register_email = "" @@ -69,7 +69,7 @@ def test_singleton_has_configuration_method( self, m, mock_captcha, mock_send_confirm ): # use cleared (from setUp() - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() self.assertFalse(config.has_form_configuration()) ContactFormSubjectFactory(config=config) @@ -97,7 +97,7 @@ def test_no_form_shown_if_not_has_configuration( self, m, mock_captcha, mock_send_confirm ): # set nothing - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() self.assertFalse(config.has_form_configuration()) response = self.app.get(self.url) @@ -107,7 +107,7 @@ def test_no_form_shown_if_not_has_configuration( def test_anon_form_requires_either_email_or_phonenumber( self, m, mock_captcha, mock_send_confirm ): - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.register_email = "example@example.com" config.save() subject = ContactFormSubjectFactory(config=config) @@ -145,7 +145,7 @@ def test_anon_form_requires_either_email_or_phonenumber( def test_regular_auth_form_fills_email_and_phonenumber( self, m, mock_captcha, mock_send_confirm ): - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.register_email = "example@example.com" config.save() subject = ContactFormSubjectFactory(config=config) @@ -170,7 +170,7 @@ def test_regular_auth_form_fills_email_and_phonenumber( def test_expected_ordered_subjects_are_shown( self, m, mock_captcha, mock_send_confirm ): - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.register_email = "example@example.com" config.save() subject_1 = ContactFormSubjectFactory(config=config) @@ -207,7 +207,7 @@ def test_expected_ordered_subjects_are_shown( mock_send_confirm.assert_not_called() def test_register_contactmoment_via_email(self, m, mock_captcha, mock_send_confirm): - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.register_email = "example@example.com" config.has_form_configuration = True config.save() @@ -252,7 +252,7 @@ def test_register_contactmoment_for_anon_user_via_api( ): MockAPICreateData.setUpServices() - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.register_contact_moment = True config.register_bronorganisatie_rsin = "123456789" config.register_type = "Melding" @@ -319,7 +319,7 @@ def test_register_contactmoment_for_anon_user_via_api_does_not_send_empty_email_ # we need to patch the captcha Q&A twice because they are re-generated by the form mock_captcha2.return_value = ("", 42) - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.register_contact_moment = True config.register_bronorganisatie_rsin = "123456789" config.register_type = "Melding" @@ -379,7 +379,7 @@ def test_register_contactmoment_for_bsn_user_via_api( ): MockAPICreateData.setUpServices() - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.register_contact_moment = True config.register_bronorganisatie_rsin = "123456789" config.register_type = "Melding" @@ -455,7 +455,7 @@ def test_register_contactmoment_for_bsn_user_via_api_without_id( ): MockAPICreateData.setUpServices() - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.register_contact_moment = True config.register_bronorganisatie_rsin = "123456789" config.register_type = "Melding" @@ -508,7 +508,7 @@ def test_register_contactmoment_for_kvk_or_rsin_user_via_api( ): MockAPICreateData.setUpServices() - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.register_contact_moment = True config.register_bronorganisatie_rsin = "123456789" config.register_type = "Melding" @@ -613,7 +613,7 @@ def test_register_contactmoment_for_bsn_user_via_api_and_update_klant( ): MockAPICreateData.setUpServices() - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.register_contact_moment = True config.register_bronorganisatie_rsin = "123456789" config.register_type = "Melding" @@ -702,7 +702,7 @@ def test_register_contactmoment_for_kvk_or_rsin_user_via_api_and_update_klant( # we need to patch the captcha Q&A twice because they are re-generated by the form mock_captcha2.return_value = ("", 42) - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.register_contact_moment = True config.register_bronorganisatie_rsin = "123456789" config.register_type = "Melding" @@ -809,7 +809,7 @@ def test_send_email_confirmation_is_configurable( # we need to patch the captcha Q&A twice because they are re-generated by the form mock_captcha2.return_value = ("", 42) - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.register_contact_moment = True config.register_bronorganisatie_rsin = "123456789" config.register_type = "Melding" diff --git a/src/open_inwoner/openklant/tests/test_esuite_vragen_service.py b/src/open_inwoner/openklant/tests/test_esuite_vragen_service.py index 99cfa248cc..cd154c93e4 100644 --- a/src/open_inwoner/openklant/tests/test_esuite_vragen_service.py +++ b/src/open_inwoner/openklant/tests/test_esuite_vragen_service.py @@ -6,7 +6,7 @@ from open_inwoner.accounts.tests.factories import UserFactory from open_inwoner.openklant.constants import KlantenServiceType, Status -from open_inwoner.openklant.models import ContactFormSubject, OpenKlantConfig +from open_inwoner.openklant.models import ContactFormSubject, ESuiteKlantConfig from open_inwoner.openklant.services import eSuiteVragenService from open_inwoner.openklant.tests.data import MockAPIReadData from open_inwoner.utils.url import uuid_from_url @@ -22,7 +22,7 @@ def setUp(self): MockAPIReadData.setUpServices() self.service = eSuiteVragenService() self.user = UserFactory() - klanten_config = OpenKlantConfig.get_solo() + klanten_config = ESuiteKlantConfig.get_solo() klanten_config.exclude_contactmoment_kanalen = ["intern_initiatief"] klanten_config.save() @@ -34,7 +34,7 @@ def setUp(self): def test_list_questions_returns_expected_rows(self, m): data = MockAPIReadData().install_mocks(m) - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() for user, params, expected_klantcontact, expected_contactmoment, use_rsin in ( ( @@ -105,7 +105,7 @@ def test_list_questions_returns_expected_rows(self, m): def test_retrieve_question_returns_expected_result(self, m): data = MockAPIReadData().install_mocks(m) - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() for user, params, expected_klantcontact, expected_contactmoment, use_rsin in ( ( diff --git a/src/open_inwoner/openklant/tests/test_signal.py b/src/open_inwoner/openklant/tests/test_signal.py index fe386e88f3..8b3c77e26c 100644 --- a/src/open_inwoner/openklant/tests/test_signal.py +++ b/src/open_inwoner/openklant/tests/test_signal.py @@ -8,7 +8,7 @@ from open_inwoner.accounts.models import User from open_inwoner.accounts.tests.factories import UserFactory, eHerkenningUserFactory from open_inwoner.configurations.models import SiteConfiguration -from open_inwoner.openklant.models import OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig from open_inwoner.openklant.tests.data import KLANTEN_ROOT, MockAPIReadData from open_inwoner.openzaak.tests.helpers import generate_oas_component_cached from open_inwoner.utils.test import ( @@ -175,7 +175,7 @@ def test_update_eherkenning_user_after_login(self, m): user.save() self.clearTimelineLogs() - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.use_rsin_for_innNnpId_query_parameter = ( use_rsin_for_innNnpId_query_parameter ) diff --git a/src/open_inwoner/openklant/tests/test_views.py b/src/open_inwoner/openklant/tests/test_views.py index 26c34e3e04..c045f2e9b2 100644 --- a/src/open_inwoner/openklant/tests/test_views.py +++ b/src/open_inwoner/openklant/tests/test_views.py @@ -21,8 +21,8 @@ from open_inwoner.openklant.constants import KlantenServiceType, Status from open_inwoner.openklant.models import ( ContactFormSubject, + ESuiteKlantConfig, KlantContactMomentAnswer, - OpenKlantConfig, ) from open_inwoner.openklant.services import eSuiteVragenService from open_inwoner.openklant.tests.data import MockAPIReadData @@ -65,15 +65,15 @@ def setUp(self): MockAPIReadData.setUpServices() self.api_group = ZGWApiGroupConfig.objects.get() - klanten_config = OpenKlantConfig.get_solo() - klanten_config.exclude_contactmoment_kanalen = ["intern_initiatief"] - klanten_config.save() + klant_config = ESuiteKlantConfig.get_solo() + klant_config.exclude_contactmoment_kanalen = ["intern_initiatief"] + klant_config.save() # for testing replacement of e-suite "onderwerp" code with OIP configured subject self.contactformsubject = ContactFormSubject.objects.create( subject="oip_subject", subject_code="e_suite_subject_code", - config=klanten_config, + config=klant_config, ) def test_contactmoment_list_bsn( @@ -246,7 +246,7 @@ def test_contactmoment_list_kvk_or_rsin( with self.subTest( use_rsin_for_innNnpId_query_parameter=use_rsin_for_innNnpId_query_parameter ): - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.use_rsin_for_innNnpId_query_parameter = ( use_rsin_for_innNnpId_query_parameter ) @@ -325,7 +325,7 @@ def test_contactmoment_list_vestiging( with self.subTest( use_rsin_for_innNnpId_query_parameter=use_rsin_for_innNnpId_query_parameter ): - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.use_rsin_for_innNnpId_query_parameter = ( use_rsin_for_innNnpId_query_parameter ) @@ -613,7 +613,7 @@ def test_contactmoment_list_subject_duplicate_esuite_codes( ContactFormSubject.objects.create( subject="control_subject_for_duplicate_code", subject_code=self.contactformsubject.subject_code, - config=OpenKlantConfig.get_solo(), + config=ESuiteKlantConfig.get_solo(), ) detail_url_esuite = reverse( @@ -744,7 +744,7 @@ def test_contactmoment_detail_esuite_for_kvk_or_rsin( # Avoid having a `KlantContactMomentAnswer` with the same URL for different users KlantContactMomentAnswer.objects.all().delete() - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.use_rsin_for_innNnpId_query_parameter = ( use_rsin_for_innNnpId_query_parameter ) @@ -793,7 +793,7 @@ def test_contactmoment_detail_esuite_vestiging( with self.subTest( use_rsin_for_innNnpId_query_parameter=use_rsin_for_innNnpId_query_parameter ): - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.use_rsin_for_innNnpId_query_parameter = ( use_rsin_for_innNnpId_query_parameter ) @@ -840,7 +840,7 @@ def test_cannot_access_detail_for_hoofdvestiging_as_vestiging( with self.subTest( use_rsin_for_innNnpId_query_parameter=use_rsin_for_innNnpId_query_parameter ): - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() config.use_rsin_for_innNnpId_query_parameter = ( use_rsin_for_innNnpId_query_parameter ) diff --git a/src/open_inwoner/openklant/views/contactform.py b/src/open_inwoner/openklant/views/contactform.py index ff0104462f..27d9ffbd45 100644 --- a/src/open_inwoner/openklant/views/contactform.py +++ b/src/open_inwoner/openklant/views/contactform.py @@ -22,7 +22,7 @@ build_klanten_client, ) from open_inwoner.openklant.forms import ContactForm -from open_inwoner.openklant.models import OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig from open_inwoner.openklant.views.utils import generate_question_answer_pair from open_inwoner.openklant.wrap import get_fetch_parameters from open_inwoner.utils.views import CommonPageMixin, LogMixin @@ -87,7 +87,7 @@ def get_initial(self): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() context["has_form_configuration"] = config.has_form_configuration() return context @@ -102,7 +102,7 @@ def set_result_message(self, success: bool): ) def form_valid(self, form: ContactForm): - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() email_success = False api_success = False @@ -171,7 +171,7 @@ def register_contactmoment_by_email(self, form: ContactForm, recipient_email: st def register_contactmoment_by_api( self, form: ContactForm, - klanten_config: OpenKlantConfig, + klanten_config: ESuiteKlantConfig, ) -> tuple[bool, str]: assert klanten_config.has_api_configuration() @@ -231,7 +231,7 @@ def _update_klant_with_form_data(self, klant: Klant, form_data: dict): def _create_contactmoment( self, form_data: dict, - klanten_config: OpenKlantConfig, + klanten_config: ESuiteKlantConfig, klant: Klant | None = None, ): if not (contactmoment_client := build_contactmomenten_client()): diff --git a/src/open_inwoner/openklant/wrap.py b/src/open_inwoner/openklant/wrap.py index 0b729d6f3c..2c9291b340 100644 --- a/src/open_inwoner/openklant/wrap.py +++ b/src/open_inwoner/openklant/wrap.py @@ -11,7 +11,7 @@ build_contactmomenten_client, build_klanten_client, ) -from open_inwoner.openklant.models import KlantContactMomentAnswer, OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig, KlantContactMomentAnswer from open_inwoner.utils.time import instance_is_new logger = logging.getLogger(__name__) @@ -106,7 +106,7 @@ def get_fetch_parameters( return {"user_bsn": user.bsn} elif user.kvk: kvk_or_rsin = user.kvk - config = OpenKlantConfig.get_solo() + config = ESuiteKlantConfig.get_solo() if config.use_rsin_for_innNnpId_query_parameter: kvk_or_rsin = user.rsin diff --git a/src/open_inwoner/openzaak/tests/test_case_detail.py b/src/open_inwoner/openzaak/tests/test_case_detail.py index f1edaec850..5fdbd445a0 100644 --- a/src/open_inwoner/openzaak/tests/test_case_detail.py +++ b/src/open_inwoner/openzaak/tests/test_case_detail.py @@ -32,7 +32,7 @@ KlantenServiceType, Status as ContactMomentStatus, ) -from open_inwoner.openklant.models import OpenKlantConfig +from open_inwoner.openklant.models import ESuiteKlantConfig from open_inwoner.openklant.services import eSuiteVragenService from open_inwoner.openklant.tests.factories import make_question_from_contactmoment from open_inwoner.openklant.tests.mocks import MockOpenKlant2Service @@ -124,7 +124,7 @@ def setUp(self): self.config.save() # openklant config - self.openklant_config = OpenKlantConfig.get_solo() + self.openklant_config = ESuiteKlantConfig.get_solo() self.openklant_config.contactmomenten_service = self.contactmoment_service self.openklant_config.save() diff --git a/src/open_inwoner/templates/admin/openklant/klantensysteemconfig/change_form.html b/src/open_inwoner/templates/admin/openklant/klantensysteemconfig/change_form.html new file mode 100644 index 0000000000..d3f66c3ec7 --- /dev/null +++ b/src/open_inwoner/templates/admin/openklant/klantensysteemconfig/change_form.html @@ -0,0 +1,10 @@ +{% extends "admin/solo/change_form.html" %} + +{% block content %} +
Configure the backends for retrieving Klanten data:
+ + {{ block.super }} +{% endblock content %}