Skip to content

Commit

Permalink
👌 [#2088] PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbal committed Feb 19, 2024
1 parent fd60809 commit 152a665
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/open_inwoner/cms/cases/views/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from open_inwoner.openzaak.formapi import fetch_open_submissions
from open_inwoner.openzaak.models import OpenZaakConfig
from open_inwoner.openzaak.types import UniformCase
from open_inwoner.openzaak.utils import get_fetch_parameters
from open_inwoner.openzaak.utils import get_user_fetch_parameters
from open_inwoner.utils.mixins import PaginationMixin
from open_inwoner.utils.views import CommonPageMixin

Expand Down Expand Up @@ -61,7 +61,7 @@ def get_cases(self):
if client is None:
return []

raw_cases = client.fetch_cases(**get_fetch_parameters(self.request))
raw_cases = client.fetch_cases(**get_user_fetch_parameters(self.request))

preprocessed_cases = preprocess_data(raw_cases)
return preprocessed_cases
Expand Down
15 changes: 10 additions & 5 deletions src/open_inwoner/openzaak/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@
class ZakenClient(APIClient):
def fetch_cases(
self,
user_bsn=None,
user_kvk_or_rsin=None,
max_requests=4,
identificatie=None,
vestigingsnummer=None,
user_bsn: Optional[str] = None,
user_kvk_or_rsin: Optional[str] = None,
max_requests: int = 4,
identificatie: Optional[str] = None,
vestigingsnummer: Optional[str] = None,
):
if user_bsn and (user_kvk_or_rsin or vestigingsnummer):
raise ValueError(
"either `user_bsn` or `user_kvk_or_rsin`/`vestigingsnummer` should be supplied, not both"
)

if user_bsn:
return self.fetch_cases_by_bsn(
user_bsn, max_requests=max_requests, identificatie=identificatie
Expand Down
5 changes: 4 additions & 1 deletion src/open_inwoner/openzaak/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,15 @@ def translate_single_status(status_text: str) -> str:
return ""


def get_fetch_parameters(request) -> dict:
def get_user_fetch_parameters(request) -> dict:
"""
Determine the parameters used to perform ZGW resource fetches
"""
user = request.user

if not user.is_authenticated:
return {}

if user.bsn:
return {"user_bsn": user.bsn}
elif user.kvk:
Expand Down
4 changes: 2 additions & 2 deletions src/open_inwoner/pdc/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from open_inwoner.openzaak.api_models import Zaak
from open_inwoner.openzaak.clients import build_client
from open_inwoner.openzaak.models import ZaakTypeConfig
from open_inwoner.openzaak.utils import get_fetch_parameters
from open_inwoner.openzaak.utils import get_user_fetch_parameters


class ProductQueryset(models.QuerySet):
Expand Down Expand Up @@ -56,7 +56,7 @@ def filter_by_zaken_for_request(self, request):
if client is None:
return self.none()

cases = client.fetch_cases(**get_fetch_parameters(request))
cases = client.fetch_cases(**get_user_fetch_parameters(request))

return self.filter_by_zaken(cases)

Expand Down
4 changes: 2 additions & 2 deletions src/open_inwoner/search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from open_inwoner.configurations.models import SiteConfiguration
from open_inwoner.openzaak.clients import build_client
from open_inwoner.openzaak.models import OpenZaakConfig
from open_inwoner.openzaak.utils import get_fetch_parameters
from open_inwoner.openzaak.utils import get_user_fetch_parameters
from open_inwoner.utils.mixins import PaginationMixin
from open_inwoner.utils.views import CommonPageMixin, LoginMaybeRequiredMixin, LogMixin

Expand Down Expand Up @@ -64,7 +64,7 @@ def search(self, form):
self.log_user_action(user, _("search query: {query}").format(query=query))

# Check if the query exactly matches with a case that belongs to the user
if search_params := get_fetch_parameters(self.request):
if search_params := get_user_fetch_parameters(self.request):
if client := build_client("zaak"):
cases = client.fetch_cases(**search_params, identificatie=query)
if cases and len(cases) == 1:
Expand Down

0 comments on commit 152a665

Please sign in to comment.