-
Notifications
You must be signed in to change notification settings - Fork 6
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
[#890] Downloadable zaakinformatieobject documenten #327
Conversation
@dataclass | ||
class ZaakInformatieObject(ZGWModel): | ||
url: str | ||
informatieobject: str | ||
zaak: str | ||
# aard_relatie_weergave: str | ||
titel: str | ||
# beschrijving: str | ||
registratiedatum: datetime | ||
|
||
|
||
def fetch_case_information_objects(case_url: str) -> List[ZaakInformatieObject]: | ||
client = build_client("zaak") | ||
|
||
if client is None: | ||
return [] | ||
|
||
try: | ||
response = client.list( | ||
"zaakinformatieobject", | ||
request_kwargs={ | ||
"params": {"zaak": case_url}, | ||
}, | ||
) | ||
except RequestException as e: | ||
logger.exception("exception while making request", exc_info=e) | ||
return [] | ||
except ClientError as e: | ||
logger.exception("exception while making request", exc_info=e) | ||
return [] | ||
|
||
case_info_objects = factory(ZaakInformatieObject, response) | ||
|
||
return case_info_objects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was in another file that got crowded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I'm not sure that fetching ZaakInformatieObject belongs to this file, because it requests Zaken API
For now we have 3 Openzaak APIs (Zaken, Catalogi and now Documenten) which we requests. Let's agree hot we organize functions to fetch these APIs
It can be done based on:
- API (3 files: each file to request resources from one particular API)
- openinwoner views (separate functions needed for different views per view basis, but some functions can be used in several views)
@alextreme @Bartvaderkin @vaszig let's agree to one option and stick to it?
I like the first option, I'd suggest to have 3 files - cases, catalog and documents (or zaken, catalogi and documenten) and put all functions there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the first approach. It seems the most logical to me as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with option 1. We'll need to coordinate how/when to refactor that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do it in the PR and we will merge it and rebase our branches and be done with this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the refactoring to the PR. The commit-diff is interesting as it is trying to make sense of code movements.
…formatieobject documenten
2998ac4
to
5e40ce3
Compare
Note to the reviewer: I have another ticket about stronger access control, where we check if the case/document actually belong to the current user's BSN (taiga 912) |
Codecov Report
@@ Coverage Diff @@
## develop #327 +/- ##
===========================================
+ Coverage 96.45% 96.48% +0.02%
===========================================
Files 419 426 +7
Lines 12724 12994 +270
===========================================
+ Hits 12273 12537 +264
- Misses 451 457 +6
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks nice, just several remarks
|
||
|
||
@dataclass | ||
class InformatieObject(ZGWModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not to reuse zgw_consumers.api_models.documenten.Document
class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@annashamray This was a change necessary for all due to the zgw_consumers models not being compatible with the e-Suite ZGW API, as documented here: https://taiga.maykinmedia.nl/project/open-inwoner/wiki/afwijkingen-e-suite-tov-zgw-standaard
In short, e-Suite ZGW API doesn't return all the keys in responses which zgw_consumers assumes does always return. This was at least the case this summer.
We can discuss this further IRL if necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! I completely forgot (and maybe didn't know) about e-Suite
But taiga link includes only ZaakInformatieObject
differences, it doesn't include any info about InformatieObject
resource
So I'll keep this comment unresolved, but resolve the same comment about ZaakInformatieObject
class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're correct, we didn't request IO's earlier, only ZIO's.
I expect we will also need to tweak the IO model further to get this to work with e-Suite, so having an OIP-specific IO model makes this more workable. For this current iteration we can keep the scope to only integrating with Open Zaak, once this is on staging we can do further e-Suite testing to double-check if this also works there as expected.
The alternative is that we temporarily deploy this branch on acceptance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does e-Suite just doesn't add certain fields or do they have different fields altogether?
I think we should look into fixing the factory()
function so it at least doesn't crash when fields are missing (it did that even for the IO model from ZGW and the test OpenZaak environment). Or we can keep two sets of dataclasses, one of OpenZaak and one for e-Suite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discussed with @annashamray and we leave it like this for now to land this PR, and then create an issue to look at refactoring the factory function so we can run e-Suite and OpenZaak from same dataclasses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e-Suite adheres to the same JSON responses as OpenZaak, however with less fields. But the main difference is that empty fields aren't returned in the JSON response.
If you want we can investigate this on staging together if necessary based on the acceptance environments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is just less fields then we should be able to improve the factory function to deal with that and set some default/empty values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sergei-maertens noted we can easily create E-Suite compatible dataclasses by extending the official dataclasses and overriding the problematic missing fields with fields with Optional datatype and a default value.
This would keep us from compromising our accuracy for their non-spec implementation and make the differences visible in the E-suite compatible dataclasses.
We should pick that up in a different task once this PR lands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a task for this: https://taiga.maykinmedia.nl/project/open-inwoner/task/920
@dataclass | ||
class ZaakInformatieObject(ZGWModel): | ||
url: str | ||
informatieobject: str | ||
zaak: str | ||
# aard_relatie_weergave: str | ||
titel: str | ||
# beschrijving: str | ||
registratiedatum: datetime | ||
|
||
|
||
def fetch_case_information_objects(case_url: str) -> List[ZaakInformatieObject]: | ||
client = build_client("zaak") | ||
|
||
if client is None: | ||
return [] | ||
|
||
try: | ||
response = client.list( | ||
"zaakinformatieobject", | ||
request_kwargs={ | ||
"params": {"zaak": case_url}, | ||
}, | ||
) | ||
except RequestException as e: | ||
logger.exception("exception while making request", exc_info=e) | ||
return [] | ||
except ClientError as e: | ||
logger.exception("exception while making request", exc_info=e) | ||
return [] | ||
|
||
case_info_objects = factory(ZaakInformatieObject, response) | ||
|
||
return case_info_objects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I'm not sure that fetching ZaakInformatieObject belongs to this file, because it requests Zaken API
For now we have 3 Openzaak APIs (Zaken, Catalogi and now Documenten) which we requests. Let's agree hot we organize functions to fetch these APIs
It can be done based on:
- API (3 files: each file to request resources from one particular API)
- openinwoner views (separate functions needed for different views per view basis, but some functions can be used in several views)
@alextreme @Bartvaderkin @vaszig let's agree to one option and stick to it?
I like the first option, I'd suggest to have 3 files - cases, catalog and documents (or zaken, catalogi and documenten) and put all functions there
The test coverage is very nice! |
Co-authored-by: Anna Shamray <[email protected]>
…I appropriate files
No description provided.