From 0e198ffcdb7186ddfbe2ea12a1c0c3d5b7479b8e Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 13 Sep 2022 12:52:32 +0200 Subject: [PATCH 1/2] remove unused var --- files/assets/js/comments_v.js | 1 - 1 file changed, 1 deletion(-) diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index aa7538312..6584c6380 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -240,7 +240,6 @@ function post_comment(fullname, hide){ if (data && data["comment"]) { if (hide) document.getElementById(hide).classList.add('d-none'); - let id = fullname.split('_')[1]; let name = 'comment-form-space-' + fullname; commentForm = document.getElementById(name); From d3e8a7f86cdb9f203787a76502653e16cc44be38 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 13 Sep 2022 13:00:47 +0200 Subject: [PATCH 2/2] perserve asset_submission fields on error --- files/routes/asset_submissions.py | 20 +++++++++++--------- files/templates/submit_hats.html | 6 +++--- files/templates/submit_marseys.html | 6 +++--- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/files/routes/asset_submissions.py b/files/routes/asset_submissions.py index 0c32d62c4..8b9e6a5dc 100644 --- a/files/routes/asset_submissions.py +++ b/files/routes/asset_submissions.py @@ -49,22 +49,25 @@ def submit_marseys(v): @auth_required def submit_marsey(v): + file = request.files["image"] + name = request.values.get('name').lower().strip() + tags = request.values.get('tags').lower().strip() + username = request.values.get('author').lower().strip() + def error(error): if v.admin_level > 2: marseys = g.db.query(Marsey).filter(Marsey.submitter_id != None).all() else: marseys = g.db.query(Marsey).filter(Marsey.submitter_id == v.id).all() for marsey in marseys: marsey.author = g.db.query(User.username).filter_by(id=marsey.author_id).one()[0] marsey.submitter = g.db.query(User.username).filter_by(id=marsey.submitter_id).one()[0] - return render_template("submit_marseys.html", v=v, marseys=marseys, error=error), 400 + return render_template("submit_marseys.html", v=v, marseys=marseys, error=error, name=name, tags=tags, username=username, file=file), 400 if request.headers.get("cf-ipcountry") == "T1": return error("Image uploads are not allowed through TOR.") - file = request.files["image"] if not file or not file.content_type.startswith('image/'): return error("You need to submit an image!") - name = request.values.get('name').lower().strip() if not marsey_regex.fullmatch(name): return error("Invalid name!") @@ -72,11 +75,9 @@ def submit_marsey(v): if existing: return error("A marsey with this name already exists!") - tags = request.values.get('tags').lower().strip() if not tags_regex.fullmatch(tags): return error("Invalid tags!") - username = request.values.get('author').strip() author = get_user(username, graceful=True) if not author: return error(f"A user with the name '{username}' was not found!") @@ -199,10 +200,14 @@ def submit_hats(v): @auth_required def submit_hat(v): + name = request.values.get('name').strip() + description = request.values.get('description').strip() + username = request.values.get('author').strip() + def error(error): if v.admin_level > 2: hats = g.db.query(HatDef).filter(HatDef.submitter_id != None).all() else: hats = g.db.query(HatDef).filter(HatDef.submitter_id == v.id).all() - return render_template("submit_hats.html", v=v, hats=hats, error=error), 400 + return render_template("submit_hats.html", v=v, hats=hats, error=error, name=name, description=description, username=username), 400 if request.headers.get("cf-ipcountry") == "T1": return error("Image uploads are not allowed through TOR.") @@ -211,7 +216,6 @@ def submit_hat(v): if not file or not file.content_type.startswith('image/'): return error("You need to submit an image!") - name = request.values.get('name').strip() if not hat_regex.fullmatch(name): return error("Invalid name!") @@ -219,11 +223,9 @@ def submit_hat(v): if existing: return error("A hat with this name already exists!") - description = request.values.get('description').strip() if not description_regex.fullmatch(description): return error("Invalid description!") - username = request.values.get('author').strip() author = get_user(username, graceful=True) if not author: return error(f"A user with the name '{username}' was not found!") diff --git a/files/templates/submit_hats.html b/files/templates/submit_hats.html index 9be255a48..3495d2303 100644 --- a/files/templates/submit_hats.html +++ b/files/templates/submit_hats.html @@ -53,13 +53,13 @@ - + - + - +