Skip to content

Commit

Permalink
[#2966] Refactor logic for registering contactmomenten via general co…
Browse files Browse the repository at this point in the history
…ntactform
  • Loading branch information
Paul Schilling committed Jan 16, 2025
1 parent 0fb6313 commit c419675
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 111 deletions.
1 change: 1 addition & 0 deletions src/open_inwoner/openklant/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(self, user, request_session, *args, **kwargs):
self.user = user
self.request_session = request_session

# TODO: check for primary_backend? What in case of OK2?
config = ESuiteKlantConfig.get_solo()
self.fields["subject"].queryset = config.contactformsubject_set.all()

Expand Down
17 changes: 13 additions & 4 deletions src/open_inwoner/openklant/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ class ESuiteKlantConfig(SingletonModel):
class Meta:
verbose_name = _("eSuite Klant configuration")

def has_form_configuration(self) -> bool:
return self.has_api_configuration() and self.contactformsubject_set.exists()

def has_api_configuration(self):
return all(getattr(self, f, "") for f in self.register_api_required_fields)

Expand Down Expand Up @@ -279,8 +276,20 @@ def has_api_configuration(self):
return esuite_config.has_api_configuration()

# TODO: support `has_api_configuration` check for OK2?
return True
return False

@property
def contact_registration_enabled(self) -> bool:
return self.register_contact_email or self.has_api_configuration

@property
def has_contactform_configuration(self):
if not self.contact_registration_enabled:
return False

if self.primary_backend == KlantenServiceType.ESUITE.value:
esuite_config = ESuiteKlantConfig.get_solo()
return esuite_config.contactformsubject_set.exists()

# TODO: check conditions for OK2
return False
Loading

0 comments on commit c419675

Please sign in to comment.