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

[#2899] Integrate OpenKlantConfig and OpenKlant2Config #1520

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/open_inwoner/accounts/tests/test_profile_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand Down
6 changes: 3 additions & 3 deletions src/open_inwoner/accounts/views/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/open_inwoner/accounts/views/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand All @@ -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
Expand Down
80 changes: 40 additions & 40 deletions src/open_inwoner/cms/cases/tests/test_contactform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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")
Expand All @@ -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 = "[email protected]"
self.ok_config.register_contact_moment = False
self.ok_config.save()
self.klant_config.register_email = "[email protected]"
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")
Expand All @@ -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 = "[email protected]"
self.ok_config.save()
self.klant_config.register_email = "[email protected]"
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")
Expand All @@ -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")
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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 = "[email protected]"
self.ok_config.register_contact_moment = False
self.ok_config.save()
self.klant_config.register_email = "[email protected]"
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"]
Expand Down Expand Up @@ -708,8 +708,8 @@ def test_form_success_with_both_email_and_api(
self._setUpMocks(m)
self._setUpExtraMocks(m)

self.ok_config.register_email = "[email protected]"
self.ok_config.save()
self.klant_config.register_email = "[email protected]"
self.klant_config.save()

response = self.app.get(self.case_detail_url, user=self.user)
form = response.forms["contact-form"]
Expand Down Expand Up @@ -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()

Expand All @@ -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()

Expand Down
20 changes: 10 additions & 10 deletions src/open_inwoner/cms/cases/tests/test_htmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
15 changes: 7 additions & 8 deletions src/open_inwoner/cms/cases/views/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -986,17 +986,16 @@ 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:
ztc = ZaakTypeConfig.objects.filter_case_type(self.case.zaaktype).get()
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))
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/open_inwoner/cms/footer/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
8 changes: 4 additions & 4 deletions src/open_inwoner/cms/footer/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 = ""
Expand All @@ -25,15 +25,15 @@ 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)

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)
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/conf/app/setup_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/conf/fixtures/django-admin-index.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
],
[
"openklant",
"openklantconfig"
"esuiteklantconfig"
],
[
"openzaak",
Expand Down
Loading
Loading