Skip to content

Commit

Permalink
fix: Empty docname in wbmlo change log & track changes for WB Rules
Browse files Browse the repository at this point in the history
  • Loading branch information
marination committed Nov 28, 2023
1 parent adca96b commit d1905ac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
],
"issingle": 1,
"links": [],
"modified": "2023-09-22 14:26:40.377433",
"modified": "2023-11-27 18:59:08.307363",
"modified_by": "Administrator",
"module": "Water Body Management",
"name": "Water Body Rules",
Expand Down Expand Up @@ -80,5 +80,6 @@
}
],
"sort_field": "modified",
"sort_order": "DESC"
"sort_order": "DESC",
"track_changes": 1
}
20 changes: 13 additions & 7 deletions landa/water_body_management/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ def build_modified_change_log(entry, changed_data, event):


def build_dependency_change_log(entry, changed_data):
"""Return a pretty dict with changes in dependencies (File and WBMLO)."""
"""
Return a pretty dict with changes in dependencies (File and WBMLO).
`entry` could be creation (Version), modification (Version) or deletion (Deleted Document) events.
"""
if (
cint(entry.deleted)
and entry.doctype == "File"
Expand All @@ -183,13 +186,16 @@ def build_dependency_change_log(entry, changed_data):
return []

if entry.doctype == "Water Body Management Local Organization":
ref_water_body = frappe.db.get_value(
"Water Body Management Local Organization",
entry.docname,
"water_body",
)
if cint(entry.deleted):
ref_water_body = changed_data.get("water_body") # Deleted WBMLO
else:
ref_water_body = frappe.db.get_value( # Created/Modified WBMLO
"Water Body Management Local Organization",
entry.docname,
"water_body",
)
else:
ref_water_body = entry.attached_to_name or changed_data.attached_to_name
ref_water_body = changed_data.attached_to_name if cint(entry.deleted) else entry.attached_to_name

key = "files" if entry.doctype == "File" else "organizations"
return {
Expand Down

0 comments on commit d1905ac

Please sign in to comment.