Skip to content
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

fix(loans): anonymize notification's recipients #3809

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rero_ils/modules/loans/logs/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,6 @@ def anonymize_logs(cls, loan_pid):
record = log.to_dict()
record["loan"]["patron"]["name"] = "anonymized"
record["loan"]["patron"]["pid"] = "anonymized"
if record["record"]["type"] == "notif":
record["notification"]["recipients"] = ["anonymized"]
cls.update(log.meta.id, log["date"], record)
6 changes: 6 additions & 0 deletions tests/ui/loans/test_loans_operation_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ def test_anonymize_logs(item2_on_loan_martigny_patron_and_loan_on_loan):
logs = LoanOperationLogsSearch().get_logs_by_record_pid(loan["pid"])
assert len(logs) == 3
for log in logs:
if log["record"]["type"] == "notif":
assert log["notification"]["recipients"] == [
"[email protected]"
]
assert log["loan"]["patron"]["pid"] == patron["pid"]
assert log["loan"]["patron"]["name"] == "Roduit, Louis"

Expand All @@ -114,3 +118,5 @@ def test_anonymize_logs(item2_on_loan_martigny_patron_and_loan_on_loan):
assert log["loan"]["patron"]["hashed_pid"] == f"{md5_hash}"
assert log["loan"]["patron"].get("name") == "anonymized"
assert log["loan"]["patron"].get("pid") == "anonymized"
if log["record"]["type"] == "notif":
assert log["notification"]["recipients"] == ["anonymized"]
Loading