|
20 | 20 |
|
21 | 21 | from invenio_records.dumpers import Dumper as InvenioRecordsDumper
|
22 | 22 |
|
| 23 | +from rero_ils.modules.commons.exceptions import MissingDataException |
23 | 24 | from rero_ils.modules.documents.dumpers import \
|
24 | 25 | TitleDumper as DocumentTitleDumper
|
25 | 26 | from rero_ils.modules.holdings.api import Holding
|
@@ -82,19 +83,23 @@ class ClaimIssueNotificationDumper(InvenioRecordsDumper):
|
82 | 83 |
|
83 | 84 | def dump(self, record, data):
|
84 | 85 | """Dump an item issue for claim notification generation."""
|
85 |
| - assert record.is_issue, 'record must be an `ItemIssue` resource' |
86 |
| - assert (holding := record.holding), \ |
87 |
| - 'record must be related to an existing `Holding`' |
| 86 | + if not record.is_issue: |
| 87 | + raise TypeError('record must be an `ItemIssue` resource') |
| 88 | + if not (holding := record.holding): |
| 89 | + raise MissingDataException('item.holding') |
| 90 | + if not (vendor := holding.vendor): |
| 91 | + raise MissingDataException('item.holding.vendor') |
88 | 92 |
|
89 | 93 | data.update({
|
90 |
| - 'vendor': holding.vendor.dumps( |
| 94 | + 'vendor': vendor.dumps( |
91 | 95 | dumper=VendorClaimIssueNotificationDumper()),
|
92 |
| - 'document': holding.document.dumps(dumper=DocumentTitleDumper()), |
| 96 | + 'document': holding.document.dumps( |
| 97 | + dumper=DocumentTitleDumper()), |
93 | 98 | 'library': holding.library.dumps(
|
94 | 99 | dumper=LibrarySerialClaimNotificationDumper()),
|
95 |
| - 'holdings': holding.dumps(dumper=ClaimIssueHoldingDumper()), |
| 100 | + 'holdings': holding.dumps( |
| 101 | + dumper=ClaimIssueHoldingDumper()), |
96 | 102 | 'enumerationAndChronology': record.enumerationAndChronology,
|
97 | 103 | 'claim_counter': record.claims_count
|
98 | 104 | })
|
99 |
| - |
100 | 105 | return {k: v for k, v in data.items() if v is not None}
|
0 commit comments