From 98fe38efea2554d3f6d4610d8f9fdffed0b49bd3 Mon Sep 17 00:00:00 2001 From: sanchegm Date: Fri, 5 Jul 2024 14:26:01 -0700 Subject: [PATCH] lint comply with lint errors --- src/affiliation.py | 12 ++++++++---- src/app.py | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/affiliation.py b/src/affiliation.py index 98c7431..798392c 100644 --- a/src/affiliation.py +++ b/src/affiliation.py @@ -56,16 +56,20 @@ def __init__( self.clinvar_submitter_ids = clinvar_submitter_ids if clinvar_submitter_ids else "" self.errors: dict = {} - def save(cls, name, coordinator, coordinator_email, status, type_, family, members, approvers, clinvar_submitter_ids, id_): + @classmethod + def save(cls, values_dict, id_): + """Save user input to the DB.""" con = sqlite3.connect(DB_FILE) # type: ignore cur = con.cursor() - logger.info(type(approvers)) try: query = ("UPDATE affiliations SET name=?, coordinator=?, " "coordinator_email=?, status=?, type=?, family=?, " "members=?, approvers=?, clinvar_submitter_ids=? WHERE id=?") - cur.execute(query, (name, coordinator, coordinator_email, status, - type_, family, members, approvers, clinvar_submitter_ids, id_)) + cur.execute(query, (values_dict["name"], values_dict["coordinator"], + values_dict["coord_email"], values_dict["status"], + values_dict["type"], values_dict["family"], + values_dict["members"], values_dict["approvers"], + values_dict["clinvar_submitter_ids"], id_)) except sqlite3.Error as err: logger.error("Unable to update affiliation by ID.") logger.error("Error code: %s", err.sqlite_errorcode) diff --git a/src/app.py b/src/app.py index db3e9ca..27e2cca 100644 --- a/src/app.py +++ b/src/app.py @@ -68,20 +68,20 @@ def edit_post(affil_id): if not affil_id: return redirect(url_for("index")) affiliation = Affiliation.get_by_id(affil_id) - if affiliation.save(request.form['name'], - request.form['coordinator'], - request.form['coordinator_email'], - request.form['status'], - request.form['type'], - request.form['family'], - request.form['members'], - request.form['approvers'], - request.form['clinvar_submitter_ids'], - affil_id): + new_values = {"name": request.form['name'], + "coordinator": request.form['coordinator'], + "coord_email": request.form['coordinator_email'], + "status": request.form['status'], + "type": request.form['type'], + "family": request.form['family'], + "members": request.form['members'], + "approvers": request.form['approvers'], + "clinvar_submitter_ids": request.form['clinvar_submitter_ids'] + } + if affiliation.save(new_values, affil_id): flash("Updated Affiliation") return redirect(url_for("index")) - else: - return render_template("edit.html", affiliation=affiliation) + return render_template("edit.html", affiliation=affiliation) @app.route("/login", methods=["GET", "POST"])