updating flash colors w/ categories

revamp
lza_menace 3 years ago
parent d0ff90dd5c
commit 14a756690b

@ -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())

@ -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)

@ -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

@ -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/<id>/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/<path:filename>")

@ -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)

@ -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 %}
<div class="notification is-danger container is-light">
{% for category, message in messages %}
<div class="notification {{ category | default('is-danger') }} container is-light">
{{ message }}
</div>
{% endfor %}

@ -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