Skip to content

Commit

Permalink
Merge pull request #244 from GemeenteUtrecht/feature/lock-review-requ…
Browse files Browse the repository at this point in the history
…ests

✨ Lock review requests when done
  • Loading branch information
damm89 authored Feb 25, 2024
2 parents b1b28cc + 61b78da commit 0138d95
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/bptl/work_units/zgw/objects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,22 @@ def get_approval_toelichtingen(task: BaseTask) -> dict:
)

return {"toelichtingen": "\n\n".join(toelichtingen)}


@register
@require_objects_service
@require_objecttypes_service
def lock_review_request(task: BaseTask) -> dict:
"""
Lock review request after all reviews have been given.
**Required process variables**
* ``kownslReviewRequestId`` [str]: the identifier of the Kownsl review request.
**Sets no process variables**
"""
data = {"locked": True, "lock_reason": "Alle verzoeken zijn uitgevoerd."}
update_review_request(task, requester=None, data=data)
return dict()
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
get_approval_toelichtingen,
get_review_request_start_process_information,
get_review_response_status,
lock_review_request,
set_review_request_metadata,
)
from .utils import (
Expand Down Expand Up @@ -262,3 +263,97 @@ def test_get_approval_toelichtingen_no_reviews(self, m):
):
result = get_approval_toelichtingen(task)
self.assertEqual(result, {"toelichtingen": ""})

def test_set_review_request_metadata(self, m):
task = ExternalTask.objects.create(
**self.task_dict,
)
with patch(
"bptl.work_units.zgw.objects.services.fetch_review_request",
return_value=deepcopy(REVIEW_REQUEST_OBJECT),
):
with patch(
"bptl.work_units.zgw.objects.services.update_object_record_data",
return_value=deepcopy(REVIEW_REQUEST_OBJECT),
) as mock_update_object_record_data:
result = lock_review_request(task)

mock_update_object_record_data.assert_called_once_with(
task,
{
"url": REVIEW_REQUEST_OBJECT["url"],
"uuid": REVIEW_REQUEST_OBJECT["uuid"],
"type": REVIEW_REQUEST_OBJECT["type"],
"record": {
"index": REVIEW_REQUEST_OBJECT["record"]["index"],
"typeVersion": REVIEW_REQUEST_OBJECT["record"]["typeVersion"],
"data": {
"created": REVIEW_REQUEST_OBJECT["record"]["data"]["created"],
"documents": REVIEW_REQUEST_OBJECT["record"]["data"][
"documents"
],
"id": REVIEW_REQUEST_OBJECT["record"]["data"]["id"],
"locked": True,
"lockReason": "Alle verzoeken zijn uitgevoerd.",
"metadata": REVIEW_REQUEST_OBJECT["record"]["data"]["metadata"],
"requester": REVIEW_REQUEST_OBJECT["record"]["data"][
"requester"
],
"toelichting": REVIEW_REQUEST_OBJECT["record"]["data"][
"toelichting"
],
"zaak": REVIEW_REQUEST_OBJECT["record"]["data"]["zaak"],
"zaakeigenschappen": [],
"assignedUsers": REVIEW_REQUEST_OBJECT["record"]["data"][
"assignedUsers"
],
"isBeingReconfigured": REVIEW_REQUEST_OBJECT["record"]["data"][
"isBeingReconfigured"
],
"numReviewsGivenBeforeChange": REVIEW_REQUEST_OBJECT["record"][
"data"
]["numReviewsGivenBeforeChange"],
"reviewType": REVIEW_REQUEST_OBJECT["record"]["data"][
"reviewType"
],
"userDeadlines": REVIEW_REQUEST_OBJECT["record"]["data"][
"userDeadlines"
],
},
"geometry": REVIEW_REQUEST_OBJECT["record"]["geometry"],
"startAt": REVIEW_REQUEST_OBJECT["record"]["startAt"],
"endAt": REVIEW_REQUEST_OBJECT["record"]["endAt"],
"registrationAt": REVIEW_REQUEST_OBJECT["record"]["registrationAt"],
"correctionFor": REVIEW_REQUEST_OBJECT["record"]["correctionFor"],
"correctedBy": "None",
},
},
{
"created": REVIEW_REQUEST_OBJECT["record"]["data"]["created"],
"documents": REVIEW_REQUEST_OBJECT["record"]["data"]["documents"],
"id": REVIEW_REQUEST_OBJECT["record"]["data"]["id"],
"locked": True,
"lockReason": "Alle verzoeken zijn uitgevoerd.",
"metadata": REVIEW_REQUEST_OBJECT["record"]["data"]["metadata"],
"requester": REVIEW_REQUEST_OBJECT["record"]["data"]["requester"],
"toelichting": REVIEW_REQUEST_OBJECT["record"]["data"]["toelichting"],
"zaak": REVIEW_REQUEST_OBJECT["record"]["data"]["zaak"],
"zaakeigenschappen": [],
"assignedUsers": REVIEW_REQUEST_OBJECT["record"]["data"][
"assignedUsers"
],
"isBeingReconfigured": REVIEW_REQUEST_OBJECT["record"]["data"][
"isBeingReconfigured"
],
"numReviewsGivenBeforeChange": REVIEW_REQUEST_OBJECT["record"]["data"][
"numReviewsGivenBeforeChange"
],
"reviewType": REVIEW_REQUEST_OBJECT["record"]["data"]["reviewType"],
"userDeadlines": REVIEW_REQUEST_OBJECT["record"]["data"][
"userDeadlines"
],
},
username=None,
)

self.assertEqual(result, dict())

0 comments on commit 0138d95

Please sign in to comment.