|
|
@ -9,7 +9,7 @@ from flask import Flask, request, session, redirect
|
|
|
|
from flask import render_template, flash, url_for
|
|
|
|
from flask import render_template, flash, url_for
|
|
|
|
from flask_session import Session
|
|
|
|
from flask_session import Session
|
|
|
|
from suchwow import config
|
|
|
|
from suchwow import config
|
|
|
|
from suchwow.models import Post, Profile, Comment, Notification, db, Moderator
|
|
|
|
from suchwow.models import Post, Profile, Comment, Notification, db, Moderator, Ban
|
|
|
|
from suchwow.routes import auth, comment, post, profile, leaderboard, api
|
|
|
|
from suchwow.routes import auth, comment, post, profile, leaderboard, api
|
|
|
|
from suchwow.utils.decorators import login_required, moderator_required
|
|
|
|
from suchwow.utils.decorators import login_required, moderator_required
|
|
|
|
from suchwow.utils.helpers import post_webhook, get_latest_tipped_posts
|
|
|
|
from suchwow.utils.helpers import post_webhook, get_latest_tipped_posts
|
|
|
@ -85,7 +85,7 @@ def init():
|
|
|
|
makedirs(f"{config.DATA_FOLDER}/{i}", exist_ok=True)
|
|
|
|
makedirs(f"{config.DATA_FOLDER}/{i}", exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
# init db
|
|
|
|
# init db
|
|
|
|
db.create_tables([Post, Profile, Comment, Notification, Moderator])
|
|
|
|
db.create_tables([Post, Profile, Comment, Notification, Moderator, Ban])
|
|
|
|
|
|
|
|
|
|
|
|
@app.cli.command("post_reddit")
|
|
|
|
@app.cli.command("post_reddit")
|
|
|
|
@click.argument('last_hours')
|
|
|
|
@click.argument('last_hours')
|
|
|
@ -153,6 +153,40 @@ def remove_admin(username):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print("That moderator doesn't exist")
|
|
|
|
print("That moderator doesn't exist")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.cli.command("ban_user")
|
|
|
|
|
|
|
|
@click.argument("username")
|
|
|
|
|
|
|
|
@click.argument("reason", nargs=-1)
|
|
|
|
|
|
|
|
def ban_user(username, reason):
|
|
|
|
|
|
|
|
u = Profile.filter(username=username).first()
|
|
|
|
|
|
|
|
b = Ban.filter(user=u).first()
|
|
|
|
|
|
|
|
if b:
|
|
|
|
|
|
|
|
print("User already banned")
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
if u:
|
|
|
|
|
|
|
|
b = Ban(user=u, reason=' '.join(reason))
|
|
|
|
|
|
|
|
b.save()
|
|
|
|
|
|
|
|
print(f"Banned {username}")
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
print("That user doesn't exist")
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.cli.command("unban_user")
|
|
|
|
|
|
|
|
@click.argument("username")
|
|
|
|
|
|
|
|
def ban_user(username):
|
|
|
|
|
|
|
|
u = Profile.filter(username=username).first()
|
|
|
|
|
|
|
|
if not u:
|
|
|
|
|
|
|
|
print("That user doesn't exist")
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
b = Ban.filter(user=u).first()
|
|
|
|
|
|
|
|
if b:
|
|
|
|
|
|
|
|
b.delete_instance()
|
|
|
|
|
|
|
|
print(f"Unbanned {username}")
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
print("That user isn't banned")
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
@app.cli.command("show")
|
|
|
|
@app.cli.command("show")
|
|
|
|
@click.argument("post_id")
|
|
|
|
@click.argument("post_id")
|
|
|
|
def post_id(post_id):
|
|
|
|
def post_id(post_id):
|
|
|
|