diff options
| author | Munyoki Kilyungi | 2025-07-02 15:41:33 +0300 |
|---|---|---|
| committer | BonfaceKilz | 2025-07-07 07:58:31 +0300 |
| commit | 1a36543d0b1b9175d29a76597b33feec81b5acf1 (patch) | |
| tree | e6810df1b79e74ea3f90cadb1e151fc3d0037598 /gn3/api/case_attributes.py | |
| parent | efbbc565b70276b873d5472608333fafad08b4fb (diff) | |
| download | genenetwork3-1a36543d0b1b9175d29a76597b33feec81b5acf1.tar.gz | |
Update list_diffs to filter by change_type, remove auth check.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3/api/case_attributes.py')
| -rw-r--r-- | gn3/api/case_attributes.py | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/gn3/api/case_attributes.py b/gn3/api/case_attributes.py index 1934ec0..2714ad8 100644 --- a/gn3/api/case_attributes.py +++ b/gn3/api/case_attributes.py @@ -233,27 +233,20 @@ def edit_case_attributes(inbredset_id: int, auth_token=None) -> tuple[Response, }), 201 -@caseattr.route("/<int:inbredset_id>/diff/list", methods=["GET"]) -@require_token -def list_diffs(inbredset_id: int, auth_token=None) -> tuple[Response, int]: - """List any changes that have not been approved/rejected.""" - try: - required_access(auth_token, - inbredset_id, - ("system:inbredset:edit-case-attribute", - "system:inbredset:apply-case-attribute-edit")) - with (database_connection(current_app.config["SQL_URI"]) as conn, - conn.cursor(cursorclass=DictCursor) as cursor): - directory = (Path(current_app.config["LMDB_DATA_PATH"]) / - "case-attributes" / str(inbredset_id)) - changes = get_changes(cursor, directory=directory) - return jsonify( - changes - ), 200 - except AuthorisationError as _auth_err: - return jsonify({ - "message": ("You are not authorised to list diffs."), - }), 401 +@caseattr.route("/<int:inbredset_id>/diffs/<string:change_type>", methods=["GET"]) +def list_diffs(inbredset_id: int, change_type: str) -> tuple[Response, int]: + """List any changes that have been made by change_type.""" + with (database_connection(current_app.config["SQL_URI"]) as conn, + conn.cursor(cursorclass=DictCursor) as cursor): + directory = (Path(current_app.config["LMDB_DATA_PATH"]) / + "case-attributes" / str(inbredset_id)) + return jsonify( + get_changes( + cursor=cursor, + change_type=EditStatus[change_type], + directory=directory + ) + ), 200 @caseattr.route("/<int:inbredset_id>/approve/<int:change_id>", methods=["POST"]) |
