From 14a756690bdbd2b3af67ba8efe86c41f24961cb8 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Mon, 8 Nov 2021 01:04:58 -0800 Subject: [PATCH] updating flash colors w/ categories --- suchwow/app.py | 2 +- suchwow/routes/comment.py | 4 ++-- suchwow/routes/leaderboard.py | 2 +- suchwow/routes/post.py | 26 +++++++++++++------------- suchwow/routes/profile.py | 2 +- suchwow/templates/base.html | 6 +++--- suchwow/utils/decorators.py | 2 +- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/suchwow/app.py b/suchwow/app.py index 0b20273..708d166 100644 --- a/suchwow/app.py +++ b/suchwow/app.py @@ -50,7 +50,7 @@ def index(): try: page = int(page) except: - flash("Wow, wtf hackerman. Cool it.") + flash("Wow, wtf hackerman. Cool it.", "is-danger") page = 1 posts = Post.select().where(Post.approved==True).order_by(Post.timestamp.desc()) diff --git a/suchwow/routes/comment.py b/suchwow/routes/comment.py index bda7ae0..97a252a 100644 --- a/suchwow/routes/comment.py +++ b/suchwow/routes/comment.py @@ -10,13 +10,13 @@ bp = Blueprint("comment", "comment") @login_required def create(post_id): if not Post.filter(id=post_id): - flash("WTF, that post doesn't exist. Stop it, hackerman.") + flash("WTF, that post doesn't exist. Stop it, hackerman.", "is-danger") return redirect(url_for("index")) if request.method == "POST": comment_text = request.form.get("comment") if len(comment_text) > 300: - flash("WTF, too many characters to post, asshole.") + flash("WTF, too many characters to post, asshole.", "is-danger") return redirect(request.url) commenter = Profile.get(username=session["auth"]["preferred_username"]) post = Post.get(id=post_id) diff --git a/suchwow/routes/leaderboard.py b/suchwow/routes/leaderboard.py index 015a239..c36051e 100644 --- a/suchwow/routes/leaderboard.py +++ b/suchwow/routes/leaderboard.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta from os import path -from flask import render_template, Blueprint, request, session, flash +from flask import render_template, Blueprint, request, session from flask import send_from_directory, redirect, url_for, current_app from werkzeug.utils import secure_filename from suchwow import wownero diff --git a/suchwow/routes/post.py b/suchwow/routes/post.py index e732788..f577eb4 100644 --- a/suchwow/routes/post.py +++ b/suchwow/routes/post.py @@ -28,7 +28,7 @@ def read(id): post = Post.get(id=id) if not post.approved: if not is_moderator(get_session_user()): - flash("That post has not been approved.") + flash("That post has not been approved.", "is-warning") return redirect("/") if wallet.connected: address = wallet.get_address(account=post.account_index) @@ -47,7 +47,7 @@ def read(id): qr_code=qr_code ) else: - flash("No meme there, brah") + flash("No meme there, brah", "is-warning") return redirect(url_for("index")) @bp.route("/post/create", methods=["GET", "POST"]) @@ -58,21 +58,21 @@ def create(): submitter = get_session_user() if submitter in config.BANNED_USERS: reason = config.BANNED_USERS[submitter] - flash(f"You can't post for now: {reason}") + flash(f"You can't post for now: {reason}", "is-danger") return redirect("/") post_title = request.form.get("title") # check if the post request has the file part if "file" not in request.files: - flash("You didn't upload a caliente meme, bro! You're fuckin up!") + flash("You didn't upload a caliente meme, bro! You're fuckin up!", "is-danger") return redirect(request.url) file = request.files["file"] # if user does not select file, browser also # submit an empty part without filename if file.filename == "": - flash("You didn't upload a caliente meme, bro! You're fuckin up!") + flash("You didn't upload a caliente meme, bro! You're fuckin up!", "is-danger") return redirect(request.url) if post_title == "": - flash("You didn't give your meme a spicy title, bro! You're fuckin up!") + flash("You didn't give your meme a spicy title, bro! You're fuckin up!", "is-danger") return redirect(request.url) if file and allowed_file(file.filename): filename = "{}-{}".format( @@ -86,7 +86,7 @@ def create(): wallet = wownero.Wallet() account_index = wallet.new_account() except: - flash("Suchwow wallet is fucked up! Try again later.") + flash("Suchwow wallet is fucked up! Try again later.", "is-danger") return redirect(request.url) post = Post( title=post_title, @@ -100,7 +100,7 @@ def create(): post.save_thumbnail() url = url_for('post.read', id=post.id, _external=True) post_webhook(f"New post :doge2: [{post.id}]({url}) by `{submitter}` :neckbeard:") - flash("New post created and pending approval!") + flash("New post created and pending approval!", "is-success") return redirect(url_for("index")) return render_template("post/create.html") @@ -114,7 +114,7 @@ def approve(id): post.approved = True post.save() post_webhook(f"Post [{post.id}]({url}) approved :white_check_mark: by `{get_session_user()}` :fieri_parrot:") - flash("Approved") + flash("Approved", "is-success") if current_app.config["DEBUG"] is False: # _r = None # _d = None @@ -130,7 +130,7 @@ def approve(id): post_webhook(f"Post [{post.id}]({url}) submitted :dab_parrot: to Discord.") return redirect(url_for("mod_queue")) else: - flash("You can't approve this") + flash("You can't approve this", "is-success") return redirect(url_for("index")) @bp.route("/post//delete") @@ -147,16 +147,16 @@ def delete(id): remove(save_path) post.delete_instance() post_webhook(f"Post {post.id} deleted :dumpsterfire: by `{user}` :godmode:") - flash("Deleted that shit, brah!") + flash("Deleted that shit, brah!", "is-success") if is_mod: return redirect(url_for("mod_queue")) else: return redirect(url_for("index")) else: - flash("You can't delete a meme you don't own, brah") + flash("You can't delete a meme you don't own, brah", "is-warning") return redirect(url_for("post.read", id=post.id)) else: - flash("No meme there, brah") + flash("No meme there, brah", "is-warning") return redirect(url_for("index")) @bp.route("/uploads/") diff --git a/suchwow/routes/profile.py b/suchwow/routes/profile.py index f017ccb..4081bc0 100644 --- a/suchwow/routes/profile.py +++ b/suchwow/routes/profile.py @@ -26,7 +26,7 @@ def edit(): profile.save() return redirect(request.args.get("redirect", "/")) else: - flash("WTF bro, that's not a valid Wownero address") + flash("WTF bro, that's not a valid Wownero address", "is-warning") return redirect(request.url) if profile_exists: profile = Profile.get(username=un) diff --git a/suchwow/templates/base.html b/suchwow/templates/base.html index ed14c37..102f997 100644 --- a/suchwow/templates/base.html +++ b/suchwow/templates/base.html @@ -55,10 +55,10 @@ {% include 'navbar.html' %} -{% with messages = get_flashed_messages() %} +{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} - {% for message in messages %} -
+ {% for category, message in messages %} +
{{ message }}
{% endfor %} diff --git a/suchwow/utils/decorators.py b/suchwow/utils/decorators.py index e2380d6..7d41d3b 100644 --- a/suchwow/utils/decorators.py +++ b/suchwow/utils/decorators.py @@ -20,7 +20,7 @@ def moderator_required(f): if m: return f(*args, **kwargs) else: - flash("You are not a moderator") + flash("You are not a moderator", "is-warning") return redirect(url_for("index")) return decorated_function