From dbf175419de9699d704a172b2be2da19c942fcda Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 16 May 2022 16:47:41 +0300 Subject: Display diffs from editing in a nice table. --- wqflask/wqflask/metadata_edits.py | 12 +++++++ wqflask/wqflask/templates/case_attributes.html | 50 +++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py index b2a23f69..664e441c 100644 --- a/wqflask/wqflask/metadata_edits.py +++ b/wqflask/wqflask/metadata_edits.py @@ -708,6 +708,18 @@ def show_case_attribute_columns(): for _, diff in diff_data.items(): diff = json.loads(diff) if (m_ := diff.get("Modifications")): + if m_.get("description"): + m_["description"]["Diff"] = "\n".join( + difflib.ndiff( + [m_.get("description")["Original"]], + [m_.get("description")["Current"]] + )) + if m_.get("name"): + m_["name"]["Diff"] = "\n".join( + difflib.ndiff( + [m_.get("name")["Original"]], + [m_.get("name")["Current"]] + )) modifications.append(m_) if (d_ := diff.get("Deletions")): deletions.append(d_) diff --git a/wqflask/wqflask/templates/case_attributes.html b/wqflask/wqflask/templates/case_attributes.html index 7aa6ee73..d64efd0f 100644 --- a/wqflask/wqflask/templates/case_attributes.html +++ b/wqflask/wqflask/templates/case_attributes.html @@ -114,7 +114,55 @@ {% endfor %} - + +
Case Attribute Edits | ++ + + {{ modifications }} + {% for data in modifications %} + {% set reject_url = "" %} + {% set approve_url = "" %} + |
---|---|
+ {% if data.get("name")%}
+ Name: + Original: {{ data["name"].get("Original") }} + Current: {{ data["name"].get("Current") }} + Diff: + {{data["name"].get("Diff")}}+ {% elif data.get("description")%} + Description: + Original: {{ data["description"].get("Original") }} + Current: {{ data["description"].get("Current") }} + Diff: + {{data["description"].get("Diff")}}+ {% endif %} + |
+ + + + | +