revamp
lza_menace 2 years ago
parent 3094205362
commit aec88afc0d

@ -1,7 +1,7 @@
from flask import Flask from flask import Flask
from flask_session import Session from flask_session import Session
from suchwow.routes import auth, comment, post, profile, leaderboard, api, mod, main from suchwow.routes import auth, post, profile, leaderboard, api, mod, main
from suchwow import filters, cli from suchwow import filters, cli
@ -13,7 +13,6 @@ Session(app)
app.register_blueprint(post.bp) app.register_blueprint(post.bp)
app.register_blueprint(auth.bp) app.register_blueprint(auth.bp)
app.register_blueprint(profile.bp) app.register_blueprint(profile.bp)
app.register_blueprint(comment.bp)
app.register_blueprint(leaderboard.bp) app.register_blueprint(leaderboard.bp)
app.register_blueprint(api.bp) app.register_blueprint(api.bp)
app.register_blueprint(mod.bp) app.register_blueprint(mod.bp)

@ -1,4 +1,4 @@
from flask import Blueprint, current_app from flask import Blueprint
from arrow import get as arrow_get from arrow import get as arrow_get
from suchwow.models import Moderator from suchwow.models import Moderator

@ -1,8 +1,10 @@
from peewee import *
from random import choice from random import choice
from os import path from os import path
from datetime import datetime from datetime import datetime
from peewee import *
from PIL import Image from PIL import Image
from suchwow import wownero from suchwow import wownero
from suchwow import config from suchwow import config

@ -1,4 +1,5 @@
from flask import jsonify, Blueprint, url_for, request, abort from flask import jsonify, Blueprint, url_for, request, abort
from suchwow.models import Post from suchwow.models import Post
from suchwow import wownero from suchwow import wownero

@ -1,6 +1,8 @@
import requests
from uuid import uuid4 from uuid import uuid4
import requests
from flask import session, redirect, url_for, request, Blueprint from flask import session, redirect, url_for, request, Blueprint
from suchwow import config from suchwow import config

@ -1,30 +0,0 @@
from flask import render_template, Blueprint, flash
from flask import request, redirect, url_for, session
from suchwow.models import Post, Comment, Profile
from suchwow.utils.decorators import login_required
bp = Blueprint("comment", "comment")
@bp.route("/comment/create/post/<post_id>", methods=["GET", "POST"])
@login_required
def create(post_id):
if not Post.filter(id=post_id):
flash("WTF, that post doesn't exist. Stop it, hackerman.", "is-danger")
return redirect(url_for("main.index"))
if request.method == "POST":
comment_text = request.form.get("comment")
if len(comment_text) > 300:
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)
c = Comment(
comment=comment_text,
commenter=commenter,
post=post,
)
c.save()
return redirect(url_for("post.read", id=post_id))
return render_template("comment/create.html")

@ -1,11 +1,6 @@
from datetime import datetime, timedelta from flask import render_template, Blueprint, request
from os import path
from flask import render_template, Blueprint, request, session from suchwow.utils.helpers import get_top_posters, get_top_posts
from flask import send_from_directory, redirect, url_for, current_app
from werkzeug.utils import secure_filename
from suchwow import wownero
from suchwow.models import Post
from suchwow.utils.helpers import rw_cache, get_top_posters, get_top_posts
bp = Blueprint("leaderboard", "leaderboard") bp = Blueprint("leaderboard", "leaderboard")

@ -1,19 +1,18 @@
from datetime import datetime, timedelta
from os import path, remove from os import path, remove
from io import BytesIO from io import BytesIO
from base64 import b64encode from base64 import b64encode
from sys import audit from secrets import token_urlsafe
from qrcode import make as qrcode_make from qrcode import make as qrcode_make
from flask import render_template, Blueprint, request, session, flash from flask import render_template, Blueprint, request, flash
from flask import send_from_directory, redirect, url_for, current_app from flask import send_from_directory, redirect, url_for, current_app
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
from secrets import token_urlsafe
from suchwow import wownero from suchwow import wownero
from suchwow import config
from suchwow.models import Post, Profile, Comment, Ban from suchwow.models import Post, Profile, Comment, Ban
from suchwow.utils.decorators import login_required, profile_required, moderator_required from suchwow.utils.decorators import login_required, profile_required, moderator_required
from suchwow.utils.helpers import allowed_file, is_moderator, get_session_user from suchwow.utils.helpers import allowed_file, is_moderator, get_session_user
from suchwow.utils.helpers import post_webhook, audit_event from suchwow.utils.helpers import audit_event
from suchwow.discord import post_discord_webhook from suchwow.discord import post_discord_webhook

@ -1,10 +1,8 @@
import pickle import pickle
from os import path from os import path
from datetime import datetime, timedelta from datetime import datetime, timedelta
from json import dumps
from requests import post as r_post from flask import session
from flask import session, current_app
from suchwow.models import Moderator, Post, AuditEvent, Profile from suchwow.models import Moderator, Post, AuditEvent, Profile
from suchwow.wownero import Wallet, from_atomic from suchwow.wownero import Wallet, from_atomic
@ -35,22 +33,6 @@ def get_session_user():
return None return None
return session["auth"]["preferred_username"].strip() return session["auth"]["preferred_username"].strip()
def post_webhook(msg):
try:
if current_app.config["DEBUG"]:
msg = "[DEBUG] " + msg
data = {
"text": msg,
"channel": config.MM_CHANNEL,
"username": config.MM_USERNAME,
"icon_url": config.MM_ICON
}
res = r_post(config.MM_ENDPOINT, data=dumps(data))
res.raise_for_status()
return True
except:
return False
def get_latest_tipped_posts(): def get_latest_tipped_posts():
key_name = 'latest_tips' key_name = 'latest_tips'
posts = [] posts = []

Loading…
Cancel
Save