diff --git a/files/routes/asset_submissions.py b/files/routes/asset_submissions.py index ec4716df8..b85049df6 100644 --- a/files/routes/asset_submissions.py +++ b/files/routes/asset_submissions.py @@ -341,3 +341,47 @@ def remove_hat(v, name): os.remove(f"/asset_submissions/hats/{hat.name}") return {"message": f"'{hat.name}' removed!"} + + + +@app.get("/admin/update/marseys") +@admin_level_required(3) +def update_marseys(v): + return render_template("update_marseys.html", v=v) + + +@app.post("/admin/update/marseys") +@admin_level_required(3) +def update_marsey(v): + + file = request.files["image"] + name = request.values.get('name').lower().strip() + + def error(error): + return render_template("update_marseys.html", v=v, error=error) + + if request.headers.get("cf-ipcountry") == "T1": + return error("Image uploads are not allowed through TOR.") + + if not file or not file.content_type.startswith('image/'): + return error("You need to submit an image!") + + if not marsey_regex.fullmatch(name): + return error("Invalid name!") + + existing = g.db.query(Marsey.name).filter_by(name=name).one_or_none() + if not existing: + return error("A marsey with this name doesn't exist!") + + + highquality = f"/asset_submissions/marseys/{name}" + file.save(highquality) + with Image.open(highquality) as i: + new_path = f'/asset_submissions/marseys/original/{name}.{i.format.lower()}' + rename(highquality, new_path) + + filename = f"files/assets/images/emojis/{name}.webp" + copyfile(new_path, filename) + process_image(filename, resize=250, trim=True) + + return render_template("update_marseys.html", v=v, msg=f"'{name}' updated successfully!") \ No newline at end of file diff --git a/files/templates/admin/admin_home.html b/files/templates/admin/admin_home.html index 415c55315..ff2d0bebe 100644 --- a/files/templates/admin/admin_home.html +++ b/files/templates/admin/admin_home.html @@ -8,9 +8,9 @@ {% block content %}

 

-

Admin Tools

+

Admin Tools

-{% if v.admin_level > 2 and (SIDEBAR_THREAD or BANNER_THREAD or BADGE_THREAD or SNAPPY_THREAD) %} +{% if v.admin_level > 2 and (SITE_NAME == 'rDrama' or SIDEBAR_THREAD or BANNER_THREAD or BADGE_THREAD or SNAPPY_THREAD) %}

Add Stuff

{% endif %} diff --git a/files/templates/update_marseys.html b/files/templates/update_marseys.html new file mode 100644 index 000000000..4864d2021 --- /dev/null +++ b/files/templates/update_marseys.html @@ -0,0 +1,106 @@ +{% extends "default.html" %} + +{% block title %} +Update Marseys +{% endblock %} + +{% block pagetype %}message{% endblock %} + +{% block content %} + {% if error %} + + {% endif %} + {% if msg %} + + {% endif %} + +
+

Update Marsey

+
+
+
+
+ + +
+
+ + + +
+ + + + + +
+
+
+
+
+ + +{% endblock %} \ No newline at end of file