From eb45ceacb5d55f073a730cac26ff380253c4c878 Mon Sep 17 00:00:00 2001 From: Sidney Richards Date: Tue, 4 Feb 2025 10:18:40 +0100 Subject: [PATCH] Move eherkenning eenmanszaak flag to more natural SiteConfiguration --- src/open_inwoner/configurations/admin.py | 1 + ...tion_enable_eherkenning_for_eenmanszaak.py | 50 +++++++++++++++++++ src/open_inwoner/configurations/models.py | 10 ++++ src/open_inwoner/openzaak/admin.py | 1 - ...nfig_enable_eherkenning_for_eenmanszaak.py | 18 +++++++ src/open_inwoner/openzaak/models.py | 11 ---- 6 files changed, 79 insertions(+), 12 deletions(-) create mode 100644 src/open_inwoner/configurations/migrations/0075_siteconfiguration_enable_eherkenning_for_eenmanszaak.py create mode 100644 src/open_inwoner/openzaak/migrations/0064_remove_openzaakconfig_enable_eherkenning_for_eenmanszaak.py diff --git a/src/open_inwoner/configurations/admin.py b/src/open_inwoner/configurations/admin.py index 9481a625b4..1e8892fb74 100644 --- a/src/open_inwoner/configurations/admin.py +++ b/src/open_inwoner/configurations/admin.py @@ -131,6 +131,7 @@ class SiteConfigurationAdmin(OrderedInlineModelAdminMixin, SingletonModelAdmin): "name", "login_show", "login_allow_registration", + "enable_eherkenning_for_eenmanszaak", "login_2fa_sms", "allow_messages_file_sharing", "redirect_to", diff --git a/src/open_inwoner/configurations/migrations/0075_siteconfiguration_enable_eherkenning_for_eenmanszaak.py b/src/open_inwoner/configurations/migrations/0075_siteconfiguration_enable_eherkenning_for_eenmanszaak.py new file mode 100644 index 0000000000..cef21be309 --- /dev/null +++ b/src/open_inwoner/configurations/migrations/0075_siteconfiguration_enable_eherkenning_for_eenmanszaak.py @@ -0,0 +1,50 @@ +# Generated by Django 4.2.18 on 2025-02-04 09:07 + +import logging + +from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist +from django.db import migrations, models + +logger = logging.getLogger(__name__) + + +def copy_setting_from_openzaak_config(apps, _): + OpenZaakConfig = apps.get_model("openzaak", "OpenZaakConfig") + SiteConfiguration = apps.get_model("configurations", "SiteConfiguration") + + try: + openzaak_config = OpenZaakConfig.objects.get() # should be a singleton + site_config = SiteConfiguration.objects.get() + except (ObjectDoesNotExist, MultipleObjectsReturned) as exc: + logger.warning( + "Unable to migrate `enable_eherkenning_for_eenmanszaak` flag from OpenZaakConfig, unable to fetch singletons", + exc_info=True, + ) + else: + site_config.enable_eherkenning_for_eenmanszaak = ( + openzaak_config.enable_eherkenning_for_eenmanszaak + ) + site_config.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ("configurations", "0074_alter_siteconfiguration_accent_color_and_more"), + ("openzaak", "0063_alter_openzaakconfig_show_cases_without_status"), + ] + + operations = [ + migrations.AddField( + model_name="siteconfiguration", + name="enable_eherkenning_for_eenmanszaak", + field=models.BooleanField( + default=False, + help_text="If enabled, eenmanszaken may authenticate using eHerkenning and subsequently their kvk nummer will be used to interface with the zaken and klanten backends). If not, an eenmanszaak will be forced to use DigiD, and the user's BSN will be used instead.", + verbose_name="Allow eenmanszaken to authenticate using eHerkenning", + ), + ), + migrations.RunPython( + copy_setting_from_openzaak_config, reverse_code=migrations.RunPython.noop + ), + ] diff --git a/src/open_inwoner/configurations/models.py b/src/open_inwoner/configurations/models.py index a9aa419eaa..277db26b7e 100644 --- a/src/open_inwoner/configurations/models.py +++ b/src/open_inwoner/configurations/models.py @@ -128,6 +128,16 @@ class SiteConfiguration(SingletonModel): verbose_name=_("Login tekst"), help_text=_("Deze tekst wordt getoond op de login pagina."), ) + enable_eherkenning_for_eenmanszaak = models.BooleanField( + verbose_name=_("Allow eenmanszaken to authenticate using eHerkenning"), + help_text=_( + "If enabled, eenmanszaken may authenticate using eHerkenning and " + "subsequently their kvk nummer will be used to interface with the zaken and" + " klanten backends). If not, an eenmanszaak will be forced to use DigiD, " + " and the user's BSN will be used instead." + ), + default=False, + ) registration_text = models.TextField( blank=True, verbose_name=_("Registratie tekst"), diff --git a/src/open_inwoner/openzaak/admin.py b/src/open_inwoner/openzaak/admin.py index c056f1907c..30d71a93e6 100644 --- a/src/open_inwoner/openzaak/admin.py +++ b/src/open_inwoner/openzaak/admin.py @@ -87,7 +87,6 @@ class OpenZaakConfigAdmin(SingletonModelAdmin): "zaken_filter_enabled", "show_cases_without_status", "order_statuses_by_date_set", - "enable_eherkenning_for_eenmanszaak", ), }, ), diff --git a/src/open_inwoner/openzaak/migrations/0064_remove_openzaakconfig_enable_eherkenning_for_eenmanszaak.py b/src/open_inwoner/openzaak/migrations/0064_remove_openzaakconfig_enable_eherkenning_for_eenmanszaak.py new file mode 100644 index 0000000000..aca8b02ee9 --- /dev/null +++ b/src/open_inwoner/openzaak/migrations/0064_remove_openzaakconfig_enable_eherkenning_for_eenmanszaak.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.18 on 2025-02-04 09:07 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("openzaak", "0063_alter_openzaakconfig_show_cases_without_status"), + ("configurations", "0075_siteconfiguration_enable_eherkenning_for_eenmanszaak"), + ] + + operations = [ + migrations.RemoveField( + model_name="openzaakconfig", + name="enable_eherkenning_for_eenmanszaak", + ), + ] diff --git a/src/open_inwoner/openzaak/models.py b/src/open_inwoner/openzaak/models.py index 0860f2541a..cdf1256041 100644 --- a/src/open_inwoner/openzaak/models.py +++ b/src/open_inwoner/openzaak/models.py @@ -427,17 +427,6 @@ def form_service(self, service): default=False, ) - enable_eherkenning_for_eenmanszaak = models.BooleanField( - verbose_name=_("Allow eenmanszaken to authenticate using eHerkenning"), - help_text=_( - "If enabled, eenmanszaken may authenticate using eHerkenning and " - "subsequently their kvk nummer will be used to interface with the zaken and" - " klanten backends). If not, an eenmanszaak will be forced to use DigiD, " - " and the user's BSN will be used instead." - ), - default=False, - ) - derive_zaak_titel_from = models.CharField( choices=ZaakTitleDisplayChoices.choices, default=ZaakTitleDisplayChoices.zaaktype_omschrijving,