aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
authorMunyoki Kilyungi2025-07-01 16:28:58 +0300
committerBonfaceKilz2025-07-07 07:58:31 +0300
commit926826b109f8b2143271eb44eb7e064e698bcc50 (patch)
treee7c4e9e256c62670907b795727dc89500f5ed65d /gn3
parent247e461c5cafa667bf2045d730ade08bc6ccc99e (diff)
downloadgenenetwork3-926826b109f8b2143271eb44eb7e064e698bcc50.tar.gz
Fix pylint errors.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3')
-rw-r--r--gn3/api/case_attributes.py31
-rw-r--r--gn3/db/case_attributes.py5
2 files changed, 20 insertions, 16 deletions
diff --git a/gn3/api/case_attributes.py b/gn3/api/case_attributes.py
index 837d0d1..536d74d 100644
--- a/gn3/api/case_attributes.py
+++ b/gn3/api/case_attributes.py
@@ -6,13 +6,6 @@ from urllib.parse import urljoin
import requests
from MySQLdb.cursors import DictCursor
-from gn3.db.case_attributes import (
- CaseAttributeEdit,
- EditStatus,
- view_change,
- queue_edit,
- apply_change,
- get_changes)
from authlib.integrations.flask_oauth2.errors import _HTTPException
from flask import (
jsonify,
@@ -20,6 +13,13 @@ from flask import (
Response,
Blueprint,
current_app)
+from gn3.db.case_attributes import (
+ CaseAttributeEdit,
+ EditStatus,
+ view_change,
+ queue_edit,
+ apply_change,
+ get_changes)
from gn3.db_utils import Connection, database_connection
@@ -246,7 +246,8 @@ def edit_case_attributes(inbredset_id: int, auth_token=None) -> Response:
@caseattr.route("/<int:inbredset_id>/diff/list", methods=["GET"])
-def list_diffs(inbredset_id: int) -> Response:
+@require_token
+def list_diffs(inbredset_id: int, auth_token=None) -> Response:
"""List any changes that have not been approved/rejected."""
try:
required_access(auth_token,
@@ -267,9 +268,9 @@ def list_diffs(inbredset_id: int) -> Response:
}), 401
-@caseattr.route("/approve/<int:change_id>", methods=["POST"])
+@caseattr.route("/<int:inbredset_id>/approve/<int:change_id>", methods=["POST"])
@require_token
-def approve_case_attributes_diff(filename: str, auth_token=None) -> Response:
+def approve_case_attributes_diff(inbredset_id: int, change_id: int, auth_token=None) -> Response:
"""Approve the changes to the case attributes in the diff."""
try:
required_access(auth_token,
@@ -278,6 +279,7 @@ def approve_case_attributes_diff(filename: str, auth_token=None) -> Response:
with database_connection(current_app.config["SQL_URI"]) as conn, \
conn.cursor() as cursor:
match apply_change(cursor, change_type=EditStatus.rejected,
+ change_id=change_id,
directory=current_app.config["LMDB_DATA_PATH"]):
case True:
return jsonify({
@@ -296,9 +298,9 @@ def approve_case_attributes_diff(filename: str, auth_token=None) -> Response:
}), 401
-@caseattr.route("/reject/<int:change_id>", methods=["POST"])
+@caseattr.route("/<int:inbredset_id>/reject/<int:change_id>", methods=["POST"])
@require_token
-def reject_case_attributes_diff(filename: str, auth_token=None) -> Response:
+def reject_case_attributes_diff(inbredset_id: int, change_id: int, auth_token=None) -> Response:
"""Reject the changes to the case attributes in the diff."""
try:
required_access(auth_token,
@@ -308,6 +310,7 @@ def reject_case_attributes_diff(filename: str, auth_token=None) -> Response:
with database_connection(current_app.config["SQL_URI"]) as conn, \
conn.cursor() as cursor:
match apply_change(cursor, change_type=EditStatus.rejected,
+ change_id=change_id,
directory=current_app.config["LMDB_DATA_PATH"]):
case True:
return jsonify({
@@ -326,9 +329,9 @@ def reject_case_attributes_diff(filename: str, auth_token=None) -> Response:
}), 401
-@caseattr.route("/<int:change_id>/diff/view", methods=["GET"])
+@caseattr.route("/<int:inbredset_id>/diff/<int:change_id>/view", methods=["GET"])
@require_token
-def view_diff(inbredset_id: int, diff_id: int, auth_token=None) -> Response:
+def view_diff(inbredset_id: int, change_id: int, auth_token=None) -> Response:
"""View a diff."""
try:
required_access(
diff --git a/gn3/db/case_attributes.py b/gn3/db/case_attributes.py
index c164b06..b16bbdd 100644
--- a/gn3/db/case_attributes.py
+++ b/gn3/db/case_attributes.py
@@ -252,9 +252,10 @@ def get_changes(cursor, inbredset_id: int, directory: Path) -> dict:
}
-# pylint: disable[too-many-locals]
+# pylint: disable=[too-many-locals]
def apply_change(cursor, change_type: EditStatus, change_id: int, directory: Path) -> bool:
- """Applies or rejects a case attribute change and updates its status in the audit table and LMDB.
+ """Applies or rejects a case attribute change and updates its
+ status in the audit table and LMDB.
Processes a change identified by `change_id` based on the
specified `change_type` (approved or rejected). For approved