Skip to content

Commit

Permalink
Merge pull request #252 from alyf-de/change-log-wb-rules
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra authored Nov 28, 2023
2 parents 8760c19 + 71a6a61 commit b862c3d
Show file tree
Hide file tree
Showing 2 changed files with 17 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
}
21 changes: 14 additions & 7 deletions landa/water_body_management/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def get_version_log_query(from_datetime: str):
"Fish Species",
"File",
"Water Body Management Local Organization",
"Water Body Rules",
]
)
)
Expand Down Expand Up @@ -173,7 +174,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 +187,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 b862c3d

Please sign in to comment.