Skip to content

Commit

Permalink
anonymization: fix orders with patron_pid
Browse files Browse the repository at this point in the history
* fixes an error when anonymizing an order that does not have the
  patron_pid in the order lines
  • Loading branch information
ntarocco authored and kpsherva committed Jan 12, 2024
1 parent 969ae4c commit 67f5531
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion invenio_app_ils/patrons/anonymization.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def anonymize_patron_data(patron_pid, force=False):
for hit in patron_acquisitions:
acquisition = Order.get_record_by_pid(hit.pid)
for line in acquisition["order_lines"]:
if line["patron_pid"] == patron_pid:
if line.get("patron_pid") == patron_pid:
line["patron_pid"] = anonymous_patron_fields["pid"]
acquisition.commit()
current_ils_acq.order_indexer.index(acquisition)
Expand Down
21 changes: 21 additions & 0 deletions tests/data/acq_orders.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,26 @@
"pid": "acqoid-6",
"status": "ORDERED",
"provider_pid": "acq-provid-2"
},
{
"order_date": "2020-01-29",
"order_lines": [
{
"copies_ordered": 1,
"document_pid": "docid-1",
"medium": "hardcover",
"recipient": "patron",
"patron_pid": "4"
},
{
"copies_ordered": 1,
"document_pid": "docid-1",
"medium": "hardcover",
"recipient": "patron"
}
],
"pid": "acqoid-7",
"status": "RECEIVED",
"provider_pid": "acq-provid-2"
}
]

0 comments on commit 67f5531

Please sign in to comment.