From 71325bcf57c1414a9399fb5cab1f8344b7947009 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 30 Nov 2021 15:09:17 +0200 Subject: [PATCH] fdsfds --- files/assets/js/emoji_modal.js | 3 +++ files/assets/js/signup.js | 27 ++++++++++++--------------- files/classes/mod_logs.py | 2 +- files/routes/front.py | 18 ++++++++++++++++++ files/routes/settings.py | 7 +++++++ files/routes/users.py | 11 +++++------ files/templates/comments.html | 4 ++-- files/templates/emoji_modal.html | 2 +- files/templates/sign_up.html | 4 ++-- files/templates/userpage.html | 4 ++-- 10 files changed, 53 insertions(+), 29 deletions(-) diff --git a/files/assets/js/emoji_modal.js b/files/assets/js/emoji_modal.js index 6fd3d6dd4..1e4ca7a47 100644 --- a/files/assets/js/emoji_modal.js +++ b/files/assets/js/emoji_modal.js @@ -16,6 +16,9 @@ const EMOJIS_STRINGS = [ marseysob: ['cry','tear'], marseytears: ['cry','sob'], marseycarpcrying: ['fish','sob','tear'], + marseyfeelsgood:[ 'happy','pepe'], + marseyhomofascist: ['kiss'], + marseycapy: ['happy','aevann','rodent'] }, emojis: ['marseylaugh','marseyblowkiss','marseyshook','marseythumbsup','marseylove','marseyreading','marseywave','marseyjamming','marseyready','marseyscarf','marseymad','marseycry','marseyinabox','marseysad','marseyexcited','marseysleep','marseyangel','marseydead','marseyparty','marseyrain','marseyagree','marseydisagree','marseyjam','marseygasp','marseytwerking','marseysipping','marseyshrug','marseyglow','marseycope','marseyseethe','marseymerchant','marseyno','marseywalking','marseyhearts','marseybegging','marseytrans2','marseygigaretard','marseysneed','marseybaited','marseyeyeroll','marseydepressed','marseypat','marseyking','marseylong1','marseylong2','marseylong3', diff --git a/files/assets/js/signup.js b/files/assets/js/signup.js index 2d3bef819..baad1cd68 100644 --- a/files/assets/js/signup.js +++ b/files/assets/js/signup.js @@ -20,18 +20,9 @@ document.addEventListener("DOMContentLoaded", function () { const userName = document.getElementById("username-register").value; const id = document.getElementById("usernameHelpRegister"); - const API = '/is_available/' + userName; - if (userName.length >= 3) { - fetch(API) - .then(res => res.json()) - .then(json => { - if (!json[userName]) { - id.innerHTML = 'Username already taken :('; - } - }) - } - - if (!/[^a-zA-Z0-9_\-$]/.test(userName)) { + if (/[^a-zA-Z0-9_\-$]/.test(userName)) { + id.innerHTML = 'No special characters or spaces allowed.'; + } else { id.innerHTML = 'Username is a-okay!'; if (userName.length < 3) { @@ -39,10 +30,16 @@ document.addEventListener("DOMContentLoaded", function () { } else if (userName.length > 25) { id.innerHTML = 'Username must be 25 characters or less.'; } - } else { - id.innerHTML = 'No special characters or spaces allowed.'; + else { + fetch('/is_available/' + userName) + .then(res => res.json()) + .then(json => { + if (!json[userName]) { + id.innerHTML = 'Username already taken :('; + } + }) + } } - }); }); \ No newline at end of file diff --git a/files/classes/mod_logs.py b/files/classes/mod_logs.py index 8e4cf6af6..e2310965e 100644 --- a/files/classes/mod_logs.py +++ b/files/classes/mod_logs.py @@ -95,7 +95,7 @@ class ModAction(Base): elif self.target_post: if self.target_post.club: return f'{cc.upper()} ONLY' return f'{self.target_post.title.replace("<","").replace(">","")}' - elif self.target_comment_id: return f'comment' + elif self.target_comment_id: return f'comment' @property @lazy diff --git a/files/routes/front.py b/files/routes/front.py index a4107d422..f655a41a4 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -167,6 +167,24 @@ def front_all(v): g.db.add(v) g.db.commit() + if v.marseyawarded and v.marseyawarded < time.time(): + v.marseyawarded = None + send_notification(v.id, "Your marsey award has expired!") + g.db.add(v) + g.db.commit() + + if v.longpost and v.longpost < time.time(): + v.longpost = None + send_notification(v.id, "Your pizzashill award has expired!") + g.db.add(v) + g.db.commit() + + if v.bird and v.bird < time.time(): + v.bird = None + send_notification(v.id, "Your bird site award has expired!") + g.db.add(v) + g.db.commit() + if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists} else: return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page) diff --git a/files/routes/settings.py b/files/routes/settings.py index 4ddec6664..537369e7b 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -155,6 +155,13 @@ def settings_profile_post(v): msg="Your bio has been updated.") + elif request.values.get("bio") == "": + v.bio = None + v.bio_html = None + g.db.add(v) + g.db.commit() + return render_template("settings_profile.html", v=v, msg="Your bio has been updated.") + elif request.values.get("sig") == "": v.sig = None v.sig_html = None diff --git a/files/routes/users.py b/files/routes/users.py index aeef7b113..7c244a11d 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -454,12 +454,12 @@ def api_is_available(name, v): if len(name)<3 or len(name)>25: return {name:False} - name=name.replace('_','\_') + name2 = name.replace('_','\_') x= g.db.query(User).filter( or_( - User.username.ilike(name), - User.original_username.ilike(name) + User.username.ilike(name2), + User.original_username.ilike(name2) ) ).first() @@ -468,7 +468,6 @@ def api_is_available(name, v): else: return {name: True} - @app.get("/id/") def user_id(id): @@ -556,12 +555,12 @@ def u_username(username, v=None): else: return render_template("userpage_private.html", time=int(time.time()), u=u, v=v) - if hasattr(u, 'is_blocking') and u.is_blocking and (not v or v.admin_level < 2): + if v and hasattr(u, 'is_blocking') and u.is_blocking: if request.headers.get("Authorization"): return {"error": f"You are blocking @{u.username}."} else: return render_template("userpage_blocking.html", u=u, v=v) - if hasattr(u, 'is_blocked') and u.is_blocked and (not v or v.admin_level < 2): + if v and v.admin_level < 2 and hasattr(u, 'is_blocked') and u.is_blocked: if request.headers.get("Authorization"): return {"error": "This person is blocking you."} else: return render_template("userpage_blocked.html", u=u, v=v) diff --git a/files/templates/comments.html b/files/templates/comments.html index 37f98335b..a0f7787e0 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -207,7 +207,7 @@ {{single_comment(reply, level=level+1)}} {% endfor %} - {% elif "notifications" in request.path %} + {% elif replies and "notifications" in request.path %}
{% set standalone=False %} {% for reply in replies %} @@ -579,7 +579,7 @@ {{single_comment(reply, level=level+1)}} {% endfor %}
- {% elif "notifications" in request.path %} + {% elif replies and "notifications" in request.path %}
{% set standalone=False %} {% for reply in replies %} diff --git a/files/templates/emoji_modal.html b/files/templates/emoji_modal.html index b59cd0c90..410afa1b8 100644 --- a/files/templates/emoji_modal.html +++ b/files/templates/emoji_modal.html @@ -1,4 +1,4 @@ - +