about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Nduli2024-08-29 10:52:06 +0300
committerBonfaceKilz2024-08-29 15:31:34 +0300
commitf9cbfadca132f62eeca6c2eb10b7f02e05fb9a6b (patch)
tree3f562626176fe396c7e1f7cf2ad3bc2a530f393c
parent93a870ad484f641e96c04675e5f2aaad4a12c2d5 (diff)
downloadgenenetwork2-f9cbfadca132f62eeca6c2eb10b7f02e05fb9a6b.tar.gz
refactor: drop monad_requests and mark required fields
-rw-r--r--gn2/wqflask/templates/wiki/edit_wiki.html6
-rw-r--r--gn2/wqflask/views.py28
2 files changed, 17 insertions, 17 deletions
diff --git a/gn2/wqflask/templates/wiki/edit_wiki.html b/gn2/wqflask/templates/wiki/edit_wiki.html
index cee874a3..242456c4 100644
--- a/gn2/wqflask/templates/wiki/edit_wiki.html
+++ b/gn2/wqflask/templates/wiki/edit_wiki.html
@@ -25,7 +25,7 @@
 		<input type="hidden" name="symbol" value="{{ content["symbol"] }}">
 		<div class="form-group">
 		    <label for="reason" class="col-sm-2">Reason for Modification: </label>
-		    <input type="text" name="reason" size=45 maxlength=100>
+		    <input type="text" name="reason" size=45 maxlength=100 required>
 		</div>
 		<div class="form-group">
 		    <label for="species" class="col-sm-2">Species: </label>
@@ -55,11 +55,11 @@
 		</div>
 		<div class="form-group">
 		    <label for="comment" class="col-sm-2">Text: </label>
-		    <textarea name="comment" rows=5 cols=60>{{ content["comment"] }}</textarea>
+		    <textarea name="comment" rows=5 cols=60 required>{{ content["comment"] }}</textarea>
 		</div>
 		<div class="form-group">
 		    <label for="email" class="col-sm-2">Email: </label>
-		    <input type="text" name="email" value="">
+		    <input type="text" name="email" value="" required>
 		</div>
 		<div class="form-group">
 		    <label for="usercode" class="col-sm-2">User Code: </label>
diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py
index b29efd94..93b7c958 100644
--- a/gn2/wqflask/views.py
+++ b/gn2/wqflask/views.py
@@ -1502,25 +1502,22 @@ def approve_reject_diff() -> Response:
                                 diff_id=form["diff_id"]))
 
 
-@app.route("/wiki/<int:comment_id>/edit", methods=["GET", "POST"])
+@app.route("/metadata/wiki/<int:comment_id>/edit", methods=["GET", "POST"])
 def edit_wiki(comment_id: int):
     """fetch generif metadata from gn3 and display it"""
     # FIXME: better error handling
     if request.method == "GET":
-        last_wiki_content = (
-            monad_requests.get(urljoin(GN3_LOCAL_URL, f"/api/metadata/wiki/{comment_id}"))
-            .either(lambda err: err.raise_for_status(), lambda x: x.json())
-        )
+        last_wiki_resp = requests.get(urljoin(GN3_LOCAL_URL, f"/api/metadata/wiki/{comment_id}"))
+        last_wiki_resp.raise_for_status()
+        last_wiki_content = last_wiki_resp.json()
 
-        species_dict = (
-            monad_requests.get(urljoin(GN3_LOCAL_URL, "/api/metadata/wiki/species"))
-            .either(lambda err: err.raise_for_status(), lambda x: x.json())
-        )
-        categories = (
-            monad_requests.get(urljoin(GN3_LOCAL_URL, "/api/metadata/wiki/categories"))
-            .either(lambda err: err.raise_for_status(), lambda x: list(x.json().keys()))
-        )
+        species_dict_resp = requests.get(urljoin(GN3_LOCAL_URL, "/api/metadata/wiki/species"))
+        species_dict_resp.raise_for_status()
+        species_dict = species_dict_resp.json()
 
+        categories_resp = requests.get(urljoin(GN3_LOCAL_URL, "/api/metadata/wiki/categories"))
+        categories_resp.raise_for_status()
+        categories = list(categories_resp.json().keys())
         grouped_categories = [categories[i : i + 3] for i in range(0, len(categories), 3)]
 
         return render_template(
@@ -1542,6 +1539,9 @@ def edit_wiki(comment_id: int):
             "categories": post_data.getlist("genecategory"),
             "reason": post_data["reason"],
             }
-        post_res = monad_requests.post(urljoin(GN3_LOCAL_URL, f"api/metadata/wiki/{comment_id}/edit"), json=payload).either(lambda err: err.raise_for_status(), lambda success: success.json())
+        post_response = requests.post(urljoin(GN3_LOCAL_URL, f"api/metadata/wiki/{comment_id}/edit"), json=payload)
+        post_response.raise_for_status()
+        post_res = post_response.json()
+
         flash(f"Success: {post_res}", "alert-success")
         return redirect(url_for("edit_wiki", comment_id=comment_id))