Skip to content

Commit 3c01a0c

Browse files
authored
Merge pull request #43 from itk-dev-rpa/hotfix/nova-document-caseworker
Hotfix/nova document caseworker
2 parents b82980a + 4e70cf1 commit 3c01a0c

File tree

5 files changed

+43
-7
lines changed

5 files changed

+43
-7
lines changed

changelog.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [2.1.1] - 2024-04-10
11+
12+
### Fixed
13+
14+
- Documents in Nova can now have a caseworker assigned.
15+
1016
## [2.1.0] - 2024-04-09
1117

1218
### Added
@@ -88,7 +94,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8894

8995
- Initial release
9096

91-
[Unreleased] https://github.com/itk-dev-rpa/ITK-dev-shared-components/compare/2.1.0...HEAD
97+
[Unreleased] https://github.com/itk-dev-rpa/ITK-dev-shared-components/compare/2.1.1...HEAD
98+
[2.1.1] https://github.com/itk-dev-rpa/ITK-dev-shared-components/releases/tag/2.1.1
9299
[2.1.0] https://github.com/itk-dev-rpa/ITK-dev-shared-components/releases/tag/2.1.0
93100
[2.0.0] https://github.com/itk-dev-rpa/ITK-dev-shared-components/releases/tag/2.0.0
94101
[1.3.1] https://github.com/itk-dev-rpa/ITK-dev-shared-components/releases/tag/1.3.1

itk_dev_shared_components/kmd_nova/nova_documents.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import requests
1111

1212
from itk_dev_shared_components.kmd_nova.authentication import NovaAccess
13-
from itk_dev_shared_components.kmd_nova.nova_objects import Document
13+
from itk_dev_shared_components.kmd_nova.nova_objects import Document, Caseworker
1414
from itk_dev_shared_components.kmd_nova. util import datetime_from_iso_string
1515

1616

@@ -44,7 +44,8 @@ def get_documents(case_uuid: str, nova_access: NovaAccess) -> list[Document]:
4444
"approved": True,
4545
"documentDate": True,
4646
"fileExtension": True,
47-
"documentCategory": True
47+
"documentCategory": True,
48+
"caseworker": True
4849
}
4950
}
5051

@@ -55,6 +56,16 @@ def get_documents(case_uuid: str, nova_access: NovaAccess) -> list[Document]:
5556

5657
documents = []
5758
for document_dict in response.json()['documents']:
59+
60+
if 'caseworker' in document_dict:
61+
caseworker = Caseworker(
62+
uuid = document_dict['caseworker']['kspIdentity']['novaUserId'],
63+
name = document_dict['caseworker']['kspIdentity']['fullName'],
64+
ident = document_dict['caseworker']['kspIdentity']['racfId']
65+
)
66+
else:
67+
caseworker = None
68+
5869
doc = Document(
5970
uuid = document_dict['documentUuid'],
6071
document_number = document_dict['documentNumber'],
@@ -66,7 +77,8 @@ def get_documents(case_uuid: str, nova_access: NovaAccess) -> list[Document]:
6677
document_date = datetime_from_iso_string(document_dict['documentDate']),
6778
file_extension = document_dict['fileExtension'],
6879
category_name = document_dict.get('documentCategoryName'),
69-
category_uuid = document_dict.get('documentCategoryUuid')
80+
category_uuid = document_dict.get('documentCategoryUuid'),
81+
caseworker=caseworker
7082
)
7183
documents.append(doc)
7284

@@ -184,6 +196,14 @@ def attach_document_to_case(case_uuid: str, document: Document, nova_access: Nov
184196
"accessToDocuments": True
185197
}
186198

199+
if document.caseworker:
200+
payload['caseworker'] = {
201+
"kspIdentity": {
202+
"racfId": document.caseworker.ident,
203+
"fullName": document.caseworker.name
204+
}
205+
}
206+
187207
headers = {'Content-Type': 'application/json', 'Authorization': f"Bearer {nova_access.get_bearer_token()}"}
188208
response = requests.post(url, params=params, headers=headers, json=payload, timeout=60)
189209
response.raise_for_status()

itk_dev_shared_components/kmd_nova/nova_objects.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class Document:
4848
file_extension: Optional[str] = None
4949
category_name: Optional[str] = None
5050
category_uuid: Optional[str] = None
51+
caseworker: Optional[Caseworker] = None
5152

5253

5354
@dataclass(slots=True, kw_only=True)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "itk_dev_shared_components"
7-
version = "2.1.0"
7+
version = "2.1.1"
88
authors = [
99
{ name="ITK Development", email="itk-rpa@mkb.aarhus.dk" },
1010
]

tests/test_nova_api/test_documents.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from io import StringIO, BytesIO
77

88
from itk_dev_shared_components.kmd_nova.authentication import NovaAccess
9-
from itk_dev_shared_components.kmd_nova.nova_objects import Document
9+
from itk_dev_shared_components.kmd_nova.nova_objects import Document, Caseworker
1010
from itk_dev_shared_components.kmd_nova import nova_cases, nova_documents
1111

1212

@@ -36,6 +36,12 @@ def test_document_upload_download(self):
3636

3737
doc_uuid = nova_documents.upload_document(file, "Filename.txt", self.nova_access)
3838

39+
caseworker = Caseworker(
40+
name='svcitkopeno svcitkopeno',
41+
ident='AZX0080',
42+
uuid='0bacdddd-5c61-4676-9a61-b01a18cec1d5'
43+
)
44+
3945
title = f"Test document {datetime.now()}"
4046
document = Document(
4147
uuid=doc_uuid,
@@ -44,7 +50,8 @@ def test_document_upload_download(self):
4450
document_type="Internt",
4551
description="Description",
4652
approved=True,
47-
category_uuid='aa015e27-669c-4934-a661-46900351f0aa'
53+
category_uuid='aa015e27-669c-4934-a661-46900351f0aa',
54+
caseworker=caseworker
4855
)
4956

5057
nova_documents.attach_document_to_case(case.uuid, document, self.nova_access)
@@ -67,6 +74,7 @@ def test_document_upload_download(self):
6774
self.assertEqual(document.category_uuid, nova_document.category_uuid)
6875
self.assertEqual(document.description, nova_document.description)
6976
self.assertEqual(document.sensitivity, nova_document.sensitivity)
77+
self.assertEqual(document.caseworker.ident, nova_document.caseworker.ident)
7078

7179
# Download the document file and check its contents
7280
file_bytes = nova_documents.download_document_file(document.uuid, self.nova_access)

0 commit comments

Comments
 (0)