Skip to content

Commit

Permalink
[#2666] Use multiple Zaken API's to filter categories by cases
Browse files Browse the repository at this point in the history
  • Loading branch information
pi-sigma committed Aug 12, 2024
1 parent 69630e7 commit 26cf40a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/open_inwoner/cms/products/tests/test_plugin_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import requests_mock
from cms.apphook_pool import apphook_pool
from dateutil.relativedelta import relativedelta
from django_webtest import WebTest
from django_webtest import TransactionWebTest, WebTest
from furl import furl
from requests import RequestException
from zgw_consumers.api_models.constants import VertrouwelijkheidsAanduidingen
Expand Down Expand Up @@ -322,7 +322,7 @@ def test_only_published_categories_exist_in_home_page_when_logged_in_with_eherke


@override_settings(ROOT_URLCONF="open_inwoner.cms.tests.urls")
class TestCategoriesCaseFiltering(ClearCachesMixin, WebTest):
class TestCategoriesCaseFiltering(ClearCachesMixin, TransactionWebTest):
def setUp(self):
super().setUp()

Expand Down
12 changes: 7 additions & 5 deletions src/open_inwoner/pdc/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from open_inwoner.accounts.models import User
from open_inwoner.configurations.models import SiteConfiguration
from open_inwoner.openzaak.api_models import Zaak
from open_inwoner.openzaak.clients import build_zaken_client
from open_inwoner.openzaak.clients import MultiZgwClientProxy, build_zaken_clients
from open_inwoner.openzaak.models import ZaakTypeConfig
from open_inwoner.openzaak.utils import get_user_fetch_parameters

Expand Down Expand Up @@ -54,11 +54,13 @@ def filter_by_zaken_for_request(self, request):
if not request.user.bsn and not request.user.kvk:
return self

client = build_zaken_client()
if client is None:
return self.none()
clients = build_zaken_clients()
proxy_result = MultiZgwClientProxy(clients)
proxy_result = proxy_result.fetch_cases(**get_user_fetch_parameters(request))
if proxy_result.has_errors:
self.log_system_action("unable to retrieve cases", user=request.user)

cases = client.fetch_cases(**get_user_fetch_parameters(request))
cases = proxy_result.join_results()

return self.filter_by_zaken(cases)

Expand Down

0 comments on commit 26cf40a

Please sign in to comment.