diff options
author | Frederick Muriuki Muriithi | 2023-10-19 10:00:17 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-10-19 10:00:17 +0300 |
commit | ea0b092395033c68f7c4edcc6805342e89034ce7 (patch) | |
tree | 09247b2ac75f91dae6ce5d03b4b35000b764ad43 /gn3 | |
parent | 6e16566c0bfb81561104f4db6934b6d216ed4fe7 (diff) | |
download | genenetwork3-ea0b092395033c68f7c4edcc6805342e89034ce7.tar.gz |
CaseAttribute: change URL, Create diff dir, fix diff
* Change the URL for listing an inbredset group's case-attribute diffs
* Create the diff directory if it does not exist
* Add `filename` to the output sent to the browser
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/case_attributes.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/gn3/case_attributes.py b/gn3/case_attributes.py index 98ba047..2115fc9 100644 --- a/gn3/case_attributes.py +++ b/gn3/case_attributes.py @@ -398,9 +398,12 @@ def edit_case_attributes(inbredset_id: int) -> Response: "diff-filename": str(diff_filename.name) }) -@caseattr.route("/list/<int:inbredset_id>", methods=["GET"]) +@caseattr.route("/<int:inbredset_id>/diff/list", methods=["GET"]) def list_diffs(inbredset_id: int) -> Response: """List any changes that have not been approved/rejected.""" + Path(current_app.config.get("TMPDIR"), CATTR_DIFFS_DIR).mkdir( + parents=True, exist_ok=True) + def __generate_diff_files__(diffs): diff_dir = Path(current_app.config.get("TMPDIR"), CATTR_DIFFS_DIR) review_files = set(afile.name for afile in diff_dir.iterdir() @@ -434,7 +437,13 @@ def list_diffs(inbredset_id: int) -> Response: __generate_diff_files__(diffs) resp = make_response(json.dumps( - tuple(diff for diff in diffs + tuple({ + **diff, + "filename": ( + f"{diff['json_diff_data']['inbredset_id']}:::" + f"{diff['json_diff_data']['user_id']}:::" + f"{diff['time_stamp'].isoformat()}") + } for diff in diffs if diff["json_diff_data"].get("inbredset_id") == inbredset_id), cls=CAJSONEncoder)) resp.headers["Content-Type"] = "application/json" |