2021-10-15 14:08:27 +00:00
|
|
|
import time
|
|
|
|
import imagehash
|
|
|
|
from os import remove
|
|
|
|
from PIL import Image as IMAGE
|
|
|
|
|
|
|
|
from files.helpers.wrappers import *
|
|
|
|
from files.helpers.alerts import *
|
|
|
|
from files.helpers.sanitize import *
|
|
|
|
from files.helpers.markdown import *
|
|
|
|
from files.helpers.security import *
|
|
|
|
from files.helpers.get import *
|
|
|
|
from files.helpers.images import *
|
|
|
|
from files.helpers.const import *
|
|
|
|
from files.classes import *
|
|
|
|
from flask import *
|
|
|
|
from files.__main__ import app, cache, limiter
|
|
|
|
from .front import frontlist
|
|
|
|
from files.helpers.discord import add_role
|
2021-12-20 20:03:59 +00:00
|
|
|
from datetime import datetime
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
SITE_NAME = environ.get("SITE_NAME", "").strip()
|
2021-11-16 21:21:53 +00:00
|
|
|
if SITE_NAME == 'PCM': cc = "splash mountain"
|
|
|
|
else: cc = "country club"
|
2021-12-20 20:03:59 +00:00
|
|
|
month = datetime.now().strftime('%B')
|
2021-10-15 14:08:27 +00:00
|
|
|
|
2021-12-20 21:04:15 +00:00
|
|
|
@app.get("/admin/grassed")
|
|
|
|
@admin_level_required(3)
|
|
|
|
def grassed(v):
|
|
|
|
users = g.db.query(User).filter(User.ban_reason.like('grass award used by @%')).all()
|
|
|
|
|
|
|
|
if not v or v.oldsite: template = ''
|
|
|
|
else: template = 'CHRISTMAS/'
|
|
|
|
return render_template(f"{template}grassed.html", v=v, users=users)
|
|
|
|
|
2021-12-23 18:43:52 +00:00
|
|
|
@app.get("/distribute/<comment>")
|
2021-12-23 18:40:30 +00:00
|
|
|
@limiter.limit("1/second")
|
2021-12-11 03:32:43 +00:00
|
|
|
@admin_level_required(3)
|
2021-12-11 03:07:51 +00:00
|
|
|
def distribute(v, cid):
|
2021-12-11 03:18:14 +00:00
|
|
|
try: int(cid)
|
|
|
|
except: abort(400)
|
2021-12-23 18:43:52 +00:00
|
|
|
post = g.db.query(Comment).filter_by(id=comment).first().post
|
2021-12-23 18:18:25 +00:00
|
|
|
|
|
|
|
pool = 0
|
|
|
|
for option in post.bet_options: pool += option.upvotes
|
2021-12-23 18:30:34 +00:00
|
|
|
pool *= 200
|
|
|
|
|
2021-12-23 18:43:52 +00:00
|
|
|
votes = g.db.query(CommentVote).filter_by(comment_id=comment)
|
2021-12-23 18:18:25 +00:00
|
|
|
coinsperperson = int(pool / votes.count())
|
|
|
|
|
2021-12-23 18:28:20 +00:00
|
|
|
cid = notif_comment(f"You won {coinsperperson} coins betting on [{post.permalink}]({post.permalink}) :marseyparty:")
|
2021-12-11 03:07:51 +00:00
|
|
|
for vote in votes:
|
|
|
|
u = vote.user
|
|
|
|
u.coins += coinsperperson
|
2021-12-20 20:03:59 +00:00
|
|
|
add_notif(cid, u.id)
|
2021-12-11 03:07:51 +00:00
|
|
|
|
2021-12-23 18:18:25 +00:00
|
|
|
autobetter = g.db.query(User).filter_by(id=AUTOBETTER_ID).first()
|
|
|
|
autobetter.coins -= pool
|
2021-12-11 03:07:51 +00:00
|
|
|
g.db.add(autobetter)
|
2021-12-23 18:18:25 +00:00
|
|
|
|
2021-12-23 18:28:20 +00:00
|
|
|
cid = notif_comment(f"You lost the 200 coins you bet on [{post.permalink}]({post.permalink}) :marseylaugh:")
|
2021-12-23 18:39:39 +00:00
|
|
|
cids = [x.id for x in post.bet_options]
|
2021-12-23 18:43:52 +00:00
|
|
|
cids.remove(comment)
|
2021-12-23 18:28:20 +00:00
|
|
|
votes = g.db.query(CommentVote).filter(CommentVote.comment_id.in_(cids)).all()
|
2021-12-23 18:29:38 +00:00
|
|
|
for vote in votes: add_notif(cid, vote.user.id)
|
2021-12-23 18:28:20 +00:00
|
|
|
|
2021-12-11 03:07:51 +00:00
|
|
|
g.db.commit()
|
2021-12-20 20:03:59 +00:00
|
|
|
return f"Each winner has received {coinsperperson} coins!"
|
2021-12-11 03:07:51 +00:00
|
|
|
|
2021-10-15 14:08:27 +00:00
|
|
|
@app.post("/@<username>/revert_actions")
|
|
|
|
@limiter.limit("1/second")
|
2021-12-17 03:25:05 +00:00
|
|
|
@admin_level_required(3)
|
2021-12-09 21:21:52 +00:00
|
|
|
@validate_formkey
|
2021-10-15 14:08:27 +00:00
|
|
|
def revert_actions(v, username):
|
2021-12-17 03:25:05 +00:00
|
|
|
user = get_user(username)
|
|
|
|
if not user: abort(404)
|
|
|
|
|
|
|
|
cutoff = int(time.time()) - 86400
|
|
|
|
|
2021-12-17 03:44:26 +00:00
|
|
|
posts = [x[0] for x in g.db.query(ModAction.target_submission_id).filter(ModAction.user_id == user.id, ModAction.created_utc > cutoff, ModAction.kind == 'ban_post').all()]
|
2021-12-17 03:52:05 +00:00
|
|
|
posts = g.db.query(Submission).filter(Submission.id.in_(posts)).all()
|
2021-12-17 03:50:55 +00:00
|
|
|
|
2021-12-17 03:44:26 +00:00
|
|
|
comments = [x[0] for x in g.db.query(ModAction.target_comment_id).filter(ModAction.user_id == user.id, ModAction.created_utc > cutoff, ModAction.kind == 'ban_comment').all()]
|
2021-12-17 03:52:05 +00:00
|
|
|
comments = g.db.query(Comment).filter(Comment.id.in_(comments)).all()
|
2021-12-17 03:50:55 +00:00
|
|
|
|
2021-12-17 03:25:05 +00:00
|
|
|
for item in posts + comments:
|
|
|
|
item.is_banned = False
|
|
|
|
g.db.add(item)
|
|
|
|
|
2021-12-17 03:48:44 +00:00
|
|
|
users = (x[0] for x in g.db.query(ModAction.target_user_id).filter(ModAction.user_id == user.id, ModAction.created_utc > cutoff, ModAction.kind.in_(('shadowban', 'ban_user'))).all())
|
2021-12-17 03:51:21 +00:00
|
|
|
users = g.db.query(User).filter(User.id.in_(users)).all()
|
2021-12-17 03:50:55 +00:00
|
|
|
|
2021-12-17 03:25:05 +00:00
|
|
|
for user in users:
|
|
|
|
user.shadowbanned = None
|
|
|
|
user.is_banned = 0
|
|
|
|
user.unban_utc = 0
|
|
|
|
user.ban_evade = 0
|
|
|
|
g.db.add(user)
|
|
|
|
for u in user.alts:
|
|
|
|
u.shadowbanned = None
|
|
|
|
u.is_banned = 0
|
|
|
|
u.unban_utc = 0
|
|
|
|
u.ban_evade = 0
|
|
|
|
g.db.add(u)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
2021-12-17 03:25:05 +00:00
|
|
|
g.db.commit()
|
2021-10-15 14:08:27 +00:00
|
|
|
return {"message": "Admin actions reverted!"}
|
|
|
|
|
|
|
|
@app.post("/@<username>/club_allow")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-12-09 21:21:52 +00:00
|
|
|
@validate_formkey
|
2021-10-15 14:08:27 +00:00
|
|
|
def club_allow(v, username):
|
|
|
|
|
|
|
|
u = get_user(username, v=v)
|
|
|
|
|
|
|
|
if not u: abort(404)
|
|
|
|
|
|
|
|
if u.admin_level >= v.admin_level: return {"error": "noob"}
|
|
|
|
|
|
|
|
u.club_allowed = True
|
|
|
|
g.db.add(u)
|
|
|
|
|
|
|
|
for x in u.alts_unique:
|
|
|
|
x.club_allowed = True
|
|
|
|
g.db.add(x)
|
|
|
|
|
|
|
|
g.db.commit()
|
2021-11-16 21:21:53 +00:00
|
|
|
return {"message": f"@{username} has been allowed into the {cc}!"}
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
@app.post("/@<username>/club_ban")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-12-09 21:21:52 +00:00
|
|
|
@validate_formkey
|
2021-10-15 14:08:27 +00:00
|
|
|
def club_ban(v, username):
|
|
|
|
|
|
|
|
u = get_user(username, v=v)
|
|
|
|
|
|
|
|
if not u: abort(404)
|
|
|
|
|
|
|
|
if u.admin_level >= v.admin_level: return {"error": "noob"}
|
|
|
|
|
|
|
|
u.club_allowed = False
|
|
|
|
|
|
|
|
for x in u.alts_unique:
|
|
|
|
u.club_allowed = False
|
|
|
|
g.db.add(x)
|
|
|
|
|
|
|
|
g.db.commit()
|
2021-11-16 21:21:53 +00:00
|
|
|
return {"message": f"@{username} has been kicked from the {cc}. Deserved."}
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.post("/@<username>/make_admin")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-12-09 21:21:52 +00:00
|
|
|
@validate_formkey
|
2021-10-15 14:08:27 +00:00
|
|
|
def make_admin(v, username):
|
2021-11-15 22:13:29 +00:00
|
|
|
if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host):
|
2021-10-15 14:08:27 +00:00
|
|
|
user = get_user(username)
|
|
|
|
if not user: abort(404)
|
2021-11-15 23:15:31 +00:00
|
|
|
user.admin_level = 2
|
2021-10-15 14:08:27 +00:00
|
|
|
g.db.add(user)
|
|
|
|
g.db.commit()
|
|
|
|
return {"message": "User has been made admin!"}
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/@<username>/remove_admin")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-12-09 21:21:52 +00:00
|
|
|
@validate_formkey
|
2021-10-15 14:08:27 +00:00
|
|
|
def remove_admin(v, username):
|
2021-11-15 22:13:29 +00:00
|
|
|
if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host):
|
2021-10-15 14:08:27 +00:00
|
|
|
user = get_user(username)
|
|
|
|
if not user: abort(404)
|
|
|
|
user.admin_level = 0
|
|
|
|
g.db.add(user)
|
|
|
|
g.db.commit()
|
|
|
|
return {"message": "Admin removed!"}
|
|
|
|
|
|
|
|
|
2021-11-26 19:28:55 +00:00
|
|
|
@app.post("/@<username>/make_meme_admin")
|
2021-10-15 14:08:27 +00:00
|
|
|
@limiter.limit("1/second")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-12-09 21:21:52 +00:00
|
|
|
@validate_formkey
|
2021-11-26 19:28:55 +00:00
|
|
|
def make_meme_admin(v, username):
|
2021-11-15 22:13:29 +00:00
|
|
|
if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host):
|
2021-10-15 14:08:27 +00:00
|
|
|
user = get_user(username)
|
|
|
|
if not user: abort(404)
|
|
|
|
user.admin_level = 1
|
|
|
|
g.db.add(user)
|
|
|
|
g.db.commit()
|
2021-11-26 19:28:55 +00:00
|
|
|
return {"message": "User has been made meme admin!"}
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
|
2021-11-26 19:28:55 +00:00
|
|
|
@app.post("/@<username>/remove_meme_admin")
|
2021-10-15 14:08:27 +00:00
|
|
|
@limiter.limit("1/second")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-12-09 21:21:52 +00:00
|
|
|
@validate_formkey
|
2021-11-26 19:28:55 +00:00
|
|
|
def remove_meme_admin(v, username):
|
2021-11-15 22:13:29 +00:00
|
|
|
if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host):
|
2021-10-15 14:08:27 +00:00
|
|
|
user = get_user(username)
|
|
|
|
if not user: abort(404)
|
|
|
|
user.admin_level = 0
|
|
|
|
g.db.add(user)
|
|
|
|
g.db.commit()
|
2021-11-26 19:28:55 +00:00
|
|
|
return {"message": "Meme admin removed!"}
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.post("/admin/monthly")
|
2021-10-21 23:02:34 +00:00
|
|
|
@limiter.limit("1/day")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-12-09 21:21:52 +00:00
|
|
|
@validate_formkey
|
2021-10-15 14:08:27 +00:00
|
|
|
def monthly(v):
|
2021-11-15 22:13:29 +00:00
|
|
|
if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host):
|
2021-11-06 15:52:48 +00:00
|
|
|
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
|
2021-12-20 20:03:59 +00:00
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
for u in g.db.query(User).filter(User.patron > 0).all():
|
2021-12-02 20:18:59 +00:00
|
|
|
if u.patron == 1: procoins = 2500
|
2021-10-21 22:55:48 +00:00
|
|
|
elif u.patron == 2: procoins = 5000
|
|
|
|
elif u.patron == 3: procoins = 10000
|
|
|
|
elif u.patron == 4: procoins = 25000
|
2021-11-24 12:24:44 +00:00
|
|
|
elif u.patron == 5: procoins = 50000
|
2021-10-21 22:59:19 +00:00
|
|
|
u.procoins += procoins
|
2021-10-21 22:55:48 +00:00
|
|
|
g.db.add(u)
|
2021-12-20 20:03:59 +00:00
|
|
|
|
|
|
|
cid = notif_comment(f"You were given {procoins} Marseybux for the month of {month}! You can use them to buy awards in the [shop](/shop).")
|
|
|
|
add_notif(cid, u.id)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
2021-10-21 22:55:48 +00:00
|
|
|
g.db.commit()
|
|
|
|
return {"message": "Monthly coins granted"}
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.get('/admin/rules')
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
def get_rules(v):
|
|
|
|
|
|
|
|
try:
|
2021-12-14 21:32:58 +00:00
|
|
|
with open(f'rules_{SITE_NAME}.html', 'r') as f: rules = f.read()
|
2021-10-15 14:08:27 +00:00
|
|
|
except Exception:
|
|
|
|
rules = None
|
|
|
|
|
|
|
|
return render_template('admin/rules.html', v=v, rules=rules)
|
|
|
|
|
|
|
|
|
|
|
|
@app.post('/admin/rules')
|
|
|
|
@limiter.limit("1/second")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def post_rules(v):
|
|
|
|
|
|
|
|
text = request.values.get('rules', '').strip()
|
|
|
|
|
2021-12-14 21:32:58 +00:00
|
|
|
with open(f'rules_{SITE_NAME}.html', 'w+') as f: f.write(text)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
2021-12-14 21:32:58 +00:00
|
|
|
with open(f'rules_{SITE_NAME}.html', 'r') as f: rules = f.read()
|
2021-10-25 18:08:03 +00:00
|
|
|
|
|
|
|
ma = ModAction(
|
|
|
|
kind="change_rules",
|
|
|
|
user_id=v.id,
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
|
|
|
|
g.db.commit()
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
return render_template('admin/rules.html', v=v, rules=rules)
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/admin/shadowbanned")
|
|
|
|
@auth_required
|
|
|
|
def shadowbanned(v):
|
2021-11-15 22:13:29 +00:00
|
|
|
if not (v and v.admin_level > 1): abort(404)
|
2021-11-06 15:52:48 +00:00
|
|
|
users = [x for x in g.db.query(User).filter(User.shadowbanned != None).all()]
|
2021-12-20 00:27:25 +00:00
|
|
|
if not v or v.oldsite: template = ''
|
2021-12-19 13:01:28 +00:00
|
|
|
else: template = 'CHRISTMAS/'
|
|
|
|
return render_template(f"{template}shadowbanned.html", v=v, users=users)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
@app.get("/admin/agendaposters")
|
|
|
|
@auth_required
|
|
|
|
def agendaposters(v):
|
2021-11-15 22:13:29 +00:00
|
|
|
if not (v and v.admin_level > 1): abort(404)
|
2021-11-06 15:52:48 +00:00
|
|
|
users = [x for x in g.db.query(User).filter_by(agendaposter = True).all()]
|
2021-12-20 00:27:25 +00:00
|
|
|
if not v or v.oldsite: template = ''
|
2021-12-19 13:01:28 +00:00
|
|
|
else: template = 'CHRISTMAS/'
|
|
|
|
return render_template(f"{template}agendaposters.html", v=v, users=users)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.get("/admin/image_posts")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
def image_posts_listing(v):
|
|
|
|
|
|
|
|
try: page = int(request.values.get('page', 1))
|
|
|
|
except: page = 1
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
posts = g.db.query(Submission).order_by(Submission.id.desc())
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
firstrange = 25 * (page - 1)
|
|
|
|
secondrange = firstrange+26
|
|
|
|
posts = [x.id for x in posts if x.is_image][firstrange:secondrange]
|
|
|
|
next_exists = (len(posts) > 25)
|
|
|
|
posts = get_posts(posts[:25], v=v)
|
|
|
|
|
2021-12-20 00:27:25 +00:00
|
|
|
if not v or v.oldsite: template = ''
|
2021-12-19 13:01:28 +00:00
|
|
|
else: template = 'CHRISTMAS/'
|
|
|
|
return render_template(f"{template}admin/image_posts.html", v=v, listing=posts, next_exists=next_exists, page=page, sort="new")
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.get("/admin/reported/posts")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
def reported_posts(v):
|
|
|
|
|
|
|
|
page = max(1, int(request.values.get("page", 1)))
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
posts = g.db.query(Submission).filter_by(
|
2021-10-15 14:08:27 +00:00
|
|
|
is_approved=0,
|
|
|
|
is_banned=False
|
2021-12-17 17:55:11 +00:00
|
|
|
).join(Submission.reports).order_by(Submission.id.desc()).offset(25 * (page - 1)).limit(26)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
listing = [p.id for p in posts]
|
|
|
|
next_exists = (len(listing) > 25)
|
|
|
|
listing = listing[:25]
|
|
|
|
|
|
|
|
listing = get_posts(listing, v=v)
|
|
|
|
|
2021-12-20 00:27:25 +00:00
|
|
|
if not v or v.oldsite: template = ''
|
2021-12-19 13:01:28 +00:00
|
|
|
else: template = 'CHRISTMAS/'
|
|
|
|
return render_template(f"{template}admin/reported_posts.html",
|
2021-10-15 14:08:27 +00:00
|
|
|
next_exists=next_exists, listing=listing, page=page, v=v)
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/admin/reported/comments")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
def reported_comments(v):
|
|
|
|
|
|
|
|
page = max(1, int(request.values.get("page", 1)))
|
|
|
|
|
|
|
|
posts = g.db.query(Comment
|
2021-11-06 15:52:48 +00:00
|
|
|
).filter_by(
|
2021-10-15 14:08:27 +00:00
|
|
|
is_approved=0,
|
|
|
|
is_banned=False
|
2021-12-17 17:55:11 +00:00
|
|
|
).join(Comment.reports).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
listing = [p.id for p in posts]
|
|
|
|
next_exists = (len(listing) > 25)
|
|
|
|
listing = listing[:25]
|
|
|
|
|
|
|
|
listing = get_comments(listing, v=v)
|
|
|
|
|
2021-12-20 00:27:25 +00:00
|
|
|
if not v or v.oldsite: template = ''
|
2021-12-19 13:01:28 +00:00
|
|
|
else: template = 'CHRISTMAS/'
|
|
|
|
return render_template(f"{template}admin/reported_comments.html",
|
2021-10-15 14:08:27 +00:00
|
|
|
next_exists=next_exists,
|
|
|
|
listing=listing,
|
|
|
|
page=page,
|
|
|
|
v=v,
|
|
|
|
standalone=True)
|
|
|
|
|
|
|
|
@app.get("/admin")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
def admin_home(v):
|
2021-12-14 21:32:58 +00:00
|
|
|
with open('disablesignups', 'r') as f:
|
2021-10-15 14:08:27 +00:00
|
|
|
x = f.read()
|
2021-12-20 00:27:25 +00:00
|
|
|
if not v or v.oldsite: template = ''
|
2021-12-19 13:01:28 +00:00
|
|
|
else: template = 'CHRISTMAS/'
|
|
|
|
return render_template(f"{template}admin/admin_home.html", v=v, x=x)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
@app.post("/admin/disablesignups")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def disablesignups(v):
|
2021-12-14 21:32:58 +00:00
|
|
|
with open('disablesignups', 'r') as f: content = f.read()
|
2021-10-29 17:58:38 +00:00
|
|
|
|
2021-12-14 21:32:58 +00:00
|
|
|
with open('disablesignups', 'w') as f:
|
2021-10-29 17:58:38 +00:00
|
|
|
if content == "yes":
|
2021-10-15 14:08:27 +00:00
|
|
|
f.write("no")
|
|
|
|
return {"message": "Signups enabed!"}
|
|
|
|
else:
|
|
|
|
f.write("yes")
|
|
|
|
return {"message": "Signups disabled!"}
|
|
|
|
|
|
|
|
@app.get("/admin/badge_grant")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
def badge_grant_get(v):
|
|
|
|
|
|
|
|
errors = {"already_owned": "That user already has that badge.",
|
|
|
|
"no_user": "That user doesn't exist."
|
|
|
|
}
|
|
|
|
|
2021-12-20 00:27:25 +00:00
|
|
|
if not v or v.oldsite: template = ''
|
2021-12-19 13:01:28 +00:00
|
|
|
else: template = 'CHRISTMAS/'
|
|
|
|
return render_template(f"{template}admin/badge_grant.html",
|
2021-10-15 14:08:27 +00:00
|
|
|
v=v,
|
2021-11-21 17:40:47 +00:00
|
|
|
badge_types=BADGES,
|
2021-10-15 14:08:27 +00:00
|
|
|
error=errors.get(
|
|
|
|
request.values.get("error"),
|
|
|
|
None) if request.values.get('error') else None,
|
|
|
|
msg="Badge successfully assigned" if request.values.get(
|
|
|
|
"msg") else None
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/admin/badge_grant")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def badge_grant_post(v):
|
|
|
|
|
|
|
|
user = get_user(request.values.get("username").strip(), graceful=True)
|
|
|
|
if not user: return redirect("/badge_grant?error=no_user")
|
|
|
|
|
|
|
|
try: badge_id = int(request.values.get("badge_id"))
|
|
|
|
except: abort(400)
|
|
|
|
|
2021-11-06 18:32:59 +00:00
|
|
|
existing = user.has_badge(badge_id)
|
|
|
|
if existing:
|
|
|
|
g.db.delete(existing)
|
2021-10-15 14:08:27 +00:00
|
|
|
g.db.commit()
|
|
|
|
return redirect("/admin/badge_grant")
|
|
|
|
|
2021-10-23 19:15:50 +00:00
|
|
|
new_badge = Badge(badge_id=badge_id, user_id=user.id)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
desc = request.values.get("description")
|
|
|
|
if desc: new_badge.description = desc
|
|
|
|
|
|
|
|
url = request.values.get("url")
|
|
|
|
if url: new_badge.url = url
|
|
|
|
|
|
|
|
g.db.add(new_badge)
|
|
|
|
g.db.flush()
|
|
|
|
|
|
|
|
text = f"""
|
|
|
|
@{v.username} has given you the following profile badge:
|
|
|
|
\n\n![]({new_badge.path})
|
|
|
|
\n\n{new_badge.name}
|
|
|
|
"""
|
2021-10-23 16:10:05 +00:00
|
|
|
send_notification(user.id, text)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
g.db.commit()
|
|
|
|
return redirect("/admin/badge_grant")
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/admin/users")
|
|
|
|
@admin_level_required(2)
|
|
|
|
def users_list(v):
|
|
|
|
|
|
|
|
page = int(request.values.get("page", 1))
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
users = g.db.query(User).filter_by(is_banned=0
|
2021-10-15 14:08:27 +00:00
|
|
|
).order_by(User.created_utc.desc()
|
|
|
|
).offset(25 * (page - 1)).limit(26)
|
|
|
|
|
|
|
|
users = [x for x in users]
|
|
|
|
|
|
|
|
next_exists = (len(users) > 25)
|
|
|
|
users = users[:25]
|
|
|
|
|
2021-12-20 00:27:25 +00:00
|
|
|
if not v or v.oldsite: template = ''
|
2021-12-19 13:01:28 +00:00
|
|
|
else: template = 'CHRISTMAS/'
|
|
|
|
return render_template(f"{template}admin/new_users.html",
|
2021-10-15 14:08:27 +00:00
|
|
|
v=v,
|
|
|
|
users=users,
|
|
|
|
next_exists=next_exists,
|
|
|
|
page=page,
|
|
|
|
)
|
|
|
|
|
|
|
|
@app.get("/admin/alt_votes")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
def alt_votes_get(v):
|
|
|
|
|
|
|
|
if not request.values.get("u1") or not request.values.get("u2"):
|
2021-12-20 00:27:25 +00:00
|
|
|
if not v or v.oldsite: template = ''
|
2021-12-19 13:01:28 +00:00
|
|
|
else: template = 'CHRISTMAS/'
|
|
|
|
return render_template(f"{template}admin/alt_votes.html", v=v)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
u1 = request.values.get("u1")
|
|
|
|
u2 = request.values.get("u2")
|
|
|
|
|
|
|
|
if not u1 or not u2:
|
|
|
|
return redirect("/admin/alt_votes")
|
|
|
|
|
|
|
|
u1 = get_user(u1)
|
|
|
|
u2 = get_user(u2)
|
|
|
|
|
|
|
|
u1_post_ups = g.db.query(
|
2021-11-06 15:52:48 +00:00
|
|
|
Vote.submission_id).filter_by(
|
2021-10-15 14:08:27 +00:00
|
|
|
user_id=u1.id,
|
|
|
|
vote_type=1).all()
|
|
|
|
u1_post_downs = g.db.query(
|
2021-11-06 15:52:48 +00:00
|
|
|
Vote.submission_id).filter_by(
|
2021-10-15 14:08:27 +00:00
|
|
|
user_id=u1.id,
|
|
|
|
vote_type=-1).all()
|
|
|
|
u1_comment_ups = g.db.query(
|
2021-11-06 15:52:48 +00:00
|
|
|
CommentVote.comment_id).filter_by(
|
2021-10-15 14:08:27 +00:00
|
|
|
user_id=u1.id,
|
|
|
|
vote_type=1).all()
|
|
|
|
u1_comment_downs = g.db.query(
|
2021-11-06 15:52:48 +00:00
|
|
|
CommentVote.comment_id).filter_by(
|
2021-10-15 14:08:27 +00:00
|
|
|
user_id=u1.id,
|
|
|
|
vote_type=-1).all()
|
|
|
|
u2_post_ups = g.db.query(
|
2021-11-06 15:52:48 +00:00
|
|
|
Vote.submission_id).filter_by(
|
2021-10-15 14:08:27 +00:00
|
|
|
user_id=u2.id,
|
|
|
|
vote_type=1).all()
|
|
|
|
u2_post_downs = g.db.query(
|
2021-11-06 15:52:48 +00:00
|
|
|
Vote.submission_id).filter_by(
|
2021-10-15 14:08:27 +00:00
|
|
|
user_id=u2.id,
|
|
|
|
vote_type=-1).all()
|
|
|
|
u2_comment_ups = g.db.query(
|
2021-11-06 15:52:48 +00:00
|
|
|
CommentVote.comment_id).filter_by(
|
2021-10-15 14:08:27 +00:00
|
|
|
user_id=u2.id,
|
|
|
|
vote_type=1).all()
|
|
|
|
u2_comment_downs = g.db.query(
|
2021-11-06 15:52:48 +00:00
|
|
|
CommentVote.comment_id).filter_by(
|
2021-10-15 14:08:27 +00:00
|
|
|
user_id=u2.id,
|
|
|
|
vote_type=-1).all()
|
|
|
|
|
|
|
|
data = {}
|
|
|
|
data['u1_only_post_ups'] = len(
|
|
|
|
[x for x in u1_post_ups if x not in u2_post_ups])
|
|
|
|
data['u2_only_post_ups'] = len(
|
|
|
|
[x for x in u2_post_ups if x not in u1_post_ups])
|
|
|
|
data['both_post_ups'] = len(list(set(u1_post_ups) & set(u2_post_ups)))
|
|
|
|
|
|
|
|
data['u1_only_post_downs'] = len(
|
|
|
|
[x for x in u1_post_downs if x not in u2_post_downs])
|
|
|
|
data['u2_only_post_downs'] = len(
|
|
|
|
[x for x in u2_post_downs if x not in u1_post_downs])
|
|
|
|
data['both_post_downs'] = len(
|
|
|
|
list(set(u1_post_downs) & set(u2_post_downs)))
|
|
|
|
|
|
|
|
data['u1_only_comment_ups'] = len(
|
|
|
|
[x for x in u1_comment_ups if x not in u2_comment_ups])
|
|
|
|
data['u2_only_comment_ups'] = len(
|
|
|
|
[x for x in u2_comment_ups if x not in u1_comment_ups])
|
|
|
|
data['both_comment_ups'] = len(
|
|
|
|
list(set(u1_comment_ups) & set(u2_comment_ups)))
|
|
|
|
|
|
|
|
data['u1_only_comment_downs'] = len(
|
|
|
|
[x for x in u1_comment_downs if x not in u2_comment_downs])
|
|
|
|
data['u2_only_comment_downs'] = len(
|
|
|
|
[x for x in u2_comment_downs if x not in u1_comment_downs])
|
|
|
|
data['both_comment_downs'] = len(
|
|
|
|
list(set(u1_comment_downs) & set(u2_comment_downs)))
|
|
|
|
|
|
|
|
data['u1_post_ups_unique'] = 100 * \
|
|
|
|
data['u1_only_post_ups'] // len(u1_post_ups) if u1_post_ups else 0
|
|
|
|
data['u2_post_ups_unique'] = 100 * \
|
|
|
|
data['u2_only_post_ups'] // len(u2_post_ups) if u2_post_ups else 0
|
|
|
|
data['u1_post_downs_unique'] = 100 * \
|
|
|
|
data['u1_only_post_downs'] // len(
|
|
|
|
u1_post_downs) if u1_post_downs else 0
|
|
|
|
data['u2_post_downs_unique'] = 100 * \
|
|
|
|
data['u2_only_post_downs'] // len(
|
|
|
|
u2_post_downs) if u2_post_downs else 0
|
|
|
|
|
|
|
|
data['u1_comment_ups_unique'] = 100 * \
|
|
|
|
data['u1_only_comment_ups'] // len(
|
|
|
|
u1_comment_ups) if u1_comment_ups else 0
|
|
|
|
data['u2_comment_ups_unique'] = 100 * \
|
|
|
|
data['u2_only_comment_ups'] // len(
|
|
|
|
u2_comment_ups) if u2_comment_ups else 0
|
|
|
|
data['u1_comment_downs_unique'] = 100 * \
|
|
|
|
data['u1_only_comment_downs'] // len(
|
|
|
|
u1_comment_downs) if u1_comment_downs else 0
|
|
|
|
data['u2_comment_downs_unique'] = 100 * \
|
|
|
|
data['u2_only_comment_downs'] // len(
|
|
|
|
u2_comment_downs) if u2_comment_downs else 0
|
|
|
|
|
2021-12-20 00:27:25 +00:00
|
|
|
if not v or v.oldsite: template = ''
|
2021-12-19 13:01:28 +00:00
|
|
|
else: template = 'CHRISTMAS/'
|
|
|
|
return render_template(f"{template}admin/alt_votes.html",
|
2021-10-15 14:08:27 +00:00
|
|
|
u1=u1,
|
|
|
|
u2=u2,
|
|
|
|
v=v,
|
|
|
|
data=data
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/admin/link_accounts")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def admin_link_accounts(v):
|
|
|
|
|
|
|
|
u1 = int(request.values.get("u1"))
|
|
|
|
u2 = int(request.values.get("u2"))
|
|
|
|
|
|
|
|
new_alt = Alt(
|
|
|
|
user1=u1,
|
|
|
|
user2=u2,
|
|
|
|
is_manual=True
|
|
|
|
)
|
|
|
|
|
|
|
|
g.db.add(new_alt)
|
|
|
|
|
|
|
|
g.db.commit()
|
2021-11-06 15:52:48 +00:00
|
|
|
return redirect(f"/admin/alt_votes?u1={g.db.query(User).get(u1).username}&u2={g.db.query(User).get(u2).username}")
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
|
2021-12-17 17:55:11 +00:00
|
|
|
@app.get("/admin/removed/posts")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
def admin_removed(v):
|
|
|
|
|
|
|
|
page = int(request.values.get("page", 1))
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
ids = g.db.query(Submission.id).join(User, User.id == Submission.author_id).filter(or_(Submission.is_banned==True, User.shadowbanned != None)).order_by(Submission.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
ids=[x[0] for x in ids]
|
|
|
|
|
|
|
|
next_exists = len(ids) > 25
|
|
|
|
|
|
|
|
ids = ids[:25]
|
|
|
|
|
|
|
|
posts = get_posts(ids, v=v)
|
|
|
|
|
2021-12-20 00:27:25 +00:00
|
|
|
if not v or v.oldsite: template = ''
|
2021-12-19 13:01:28 +00:00
|
|
|
else: template = 'CHRISTMAS/'
|
|
|
|
return render_template(f"{template}admin/removed_posts.html",
|
2021-10-15 14:08:27 +00:00
|
|
|
v=v,
|
|
|
|
listing=posts,
|
|
|
|
page=page,
|
|
|
|
next_exists=next_exists
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-12-17 17:55:11 +00:00
|
|
|
@app.get("/admin/removed/comments")
|
|
|
|
@admin_level_required(2)
|
|
|
|
def admin_removed_comments(v):
|
|
|
|
|
|
|
|
page = int(request.values.get("page", 1))
|
|
|
|
|
|
|
|
ids = g.db.query(Comment.id).join(User, User.id == Comment.author_id).filter(or_(Comment.is_banned==True, User.shadowbanned != None)).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
|
|
|
|
|
|
|
ids=[x[0] for x in ids]
|
|
|
|
|
|
|
|
next_exists = len(ids) > 25
|
|
|
|
|
|
|
|
ids = ids[:25]
|
|
|
|
|
|
|
|
comments = get_comments(ids, v=v)
|
|
|
|
|
2021-12-20 00:27:25 +00:00
|
|
|
if not v or v.oldsite: template = ''
|
2021-12-19 13:01:28 +00:00
|
|
|
else: template = 'CHRISTMAS/'
|
|
|
|
return render_template(f"{template}admin/removed_comments.html",
|
2021-12-17 17:55:11 +00:00
|
|
|
v=v,
|
|
|
|
listing=comments,
|
|
|
|
page=page,
|
|
|
|
next_exists=next_exists
|
|
|
|
)
|
|
|
|
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
@app.post("/agendaposter/<user_id>")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def agendaposter(user_id, v):
|
2021-11-06 15:52:48 +00:00
|
|
|
user = g.db.query(User).filter_by(id=user_id).first()
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
expiry = request.values.get("days", 0)
|
|
|
|
if expiry:
|
|
|
|
expiry = int(expiry)
|
|
|
|
expiry = g.timestamp + expiry*60*60*24
|
2021-10-21 17:01:25 +00:00
|
|
|
else: expiry = 0
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
user.agendaposter = not user.agendaposter
|
|
|
|
user.agendaposter_expires_utc = expiry
|
|
|
|
g.db.add(user)
|
|
|
|
for alt in user.alts:
|
|
|
|
if alt.admin_level > 0: break
|
|
|
|
alt.agendaposter = user.agendaposter
|
|
|
|
alt.agendaposter_expires_utc = expiry
|
|
|
|
g.db.add(alt)
|
|
|
|
|
|
|
|
note = None
|
|
|
|
|
|
|
|
if not user.agendaposter: kind = "unagendaposter"
|
|
|
|
else:
|
|
|
|
kind = "agendaposter"
|
|
|
|
note = f"for {request.values.get('days')} days" if expiry else "never expires"
|
|
|
|
|
|
|
|
ma = ModAction(
|
|
|
|
kind=kind,
|
|
|
|
user_id=v.id,
|
|
|
|
target_user_id=user.id,
|
|
|
|
note = note
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
|
|
|
|
if user.agendaposter:
|
|
|
|
if not user.has_badge(26):
|
|
|
|
badge = Badge(user_id=user.id, badge_id=26)
|
|
|
|
g.db.add(badge)
|
|
|
|
else:
|
|
|
|
badge = user.has_badge(26)
|
|
|
|
if badge: g.db.delete(badge)
|
|
|
|
|
2021-12-20 20:03:59 +00:00
|
|
|
if user.agendaposter: send_repeatable_notification(user.id, f"You have been marked by an admin as an agendaposter ({note}).")
|
|
|
|
else: send_repeatable_notification(user.id, f"You have been unmarked by an admin as an agendaposter.")
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
g.db.commit()
|
|
|
|
if user.agendaposter: return redirect(user.url)
|
|
|
|
return {"message": "Agendaposter theme disabled!"}
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/shadowban/<user_id>")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def shadowban(user_id, v):
|
2021-11-06 15:52:48 +00:00
|
|
|
user = g.db.query(User).filter_by(id=user_id).first()
|
2021-10-15 14:08:27 +00:00
|
|
|
if user.admin_level != 0: abort(403)
|
|
|
|
user.shadowbanned = v.username
|
|
|
|
g.db.add(user)
|
|
|
|
for alt in user.alts:
|
|
|
|
if alt.admin_level > 0: break
|
|
|
|
alt.shadowbanned = v.username
|
|
|
|
g.db.add(alt)
|
|
|
|
ma = ModAction(
|
|
|
|
kind="shadowban",
|
|
|
|
user_id=v.id,
|
|
|
|
target_user_id=user.id,
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
|
|
|
|
cache.delete_memoized(frontlist)
|
|
|
|
|
|
|
|
g.db.commit()
|
|
|
|
return {"message": "User shadowbanned!"}
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/unshadowban/<user_id>")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def unshadowban(user_id, v):
|
2021-11-06 15:52:48 +00:00
|
|
|
user = g.db.query(User).filter_by(id=user_id).first()
|
2021-10-15 14:08:27 +00:00
|
|
|
if user.admin_level != 0: abort(403)
|
|
|
|
user.shadowbanned = None
|
|
|
|
g.db.add(user)
|
|
|
|
for alt in user.alts:
|
|
|
|
alt.shadowbanned = None
|
|
|
|
g.db.add(alt)
|
|
|
|
|
|
|
|
ma = ModAction(
|
|
|
|
kind="unshadowban",
|
|
|
|
user_id=v.id,
|
|
|
|
target_user_id=user.id,
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
|
|
|
|
cache.delete_memoized(frontlist)
|
|
|
|
|
|
|
|
g.db.commit()
|
|
|
|
return {"message": "User unshadowbanned!"}
|
|
|
|
|
|
|
|
@app.post("/admin/verify/<user_id>")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def verify(user_id, v):
|
2021-11-06 15:52:48 +00:00
|
|
|
user = g.db.query(User).filter_by(id=user_id).first()
|
2021-10-15 14:08:27 +00:00
|
|
|
user.verified = "Verified"
|
|
|
|
g.db.add(user)
|
2021-10-25 18:08:03 +00:00
|
|
|
|
|
|
|
ma = ModAction(
|
|
|
|
kind="check",
|
|
|
|
user_id=v.id,
|
|
|
|
target_user_id=user.id,
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
|
2021-10-15 14:08:27 +00:00
|
|
|
g.db.commit()
|
|
|
|
return {"message": "User verfied!"}
|
|
|
|
|
|
|
|
@app.post("/admin/unverify/<user_id>")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def unverify(user_id, v):
|
2021-11-06 15:52:48 +00:00
|
|
|
user = g.db.query(User).filter_by(id=user_id).first()
|
2021-10-15 14:08:27 +00:00
|
|
|
user.verified = None
|
|
|
|
g.db.add(user)
|
2021-10-25 18:08:03 +00:00
|
|
|
|
|
|
|
ma = ModAction(
|
|
|
|
kind="uncheck",
|
|
|
|
user_id=v.id,
|
|
|
|
target_user_id=user.id,
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
|
2021-10-15 14:08:27 +00:00
|
|
|
g.db.commit()
|
|
|
|
return {"message": "User unverified!"}
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/admin/title_change/<user_id>")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def admin_title_change(user_id, v):
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
user = g.db.query(User).filter_by(id=user_id).first()
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
if user.admin_level != 0: abort(403)
|
|
|
|
|
|
|
|
new_name=request.values.get("title").strip()[:256]
|
|
|
|
|
|
|
|
user.customtitleplain=new_name
|
|
|
|
new_name = sanitize(new_name)
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
user=g.db.query(User).with_for_update().filter_by(id=user.id).first()
|
2021-10-15 14:08:27 +00:00
|
|
|
user.customtitle=new_name
|
2021-10-21 20:50:00 +00:00
|
|
|
if request.values.get("locked"): user.flairchanged = time.time() + 2629746
|
2021-10-15 14:08:27 +00:00
|
|
|
g.db.add(user)
|
|
|
|
|
|
|
|
if user.flairchanged: kind = "set_flair_locked"
|
|
|
|
else: kind = "set_flair_notlocked"
|
|
|
|
|
|
|
|
ma=ModAction(
|
|
|
|
kind=kind,
|
|
|
|
user_id=v.id,
|
|
|
|
target_user_id=user.id,
|
2021-12-10 16:31:38 +00:00
|
|
|
_note=f'"{user.customtitleplain}"'
|
2021-10-15 14:08:27 +00:00
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
g.db.commit()
|
|
|
|
|
|
|
|
return redirect(user.url)
|
|
|
|
|
|
|
|
@app.post("/ban_user/<user_id>")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def ban_user(user_id, v):
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
user = g.db.query(User).filter_by(id=user_id).first()
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
if user.admin_level >= v.admin_level: abort(403)
|
|
|
|
|
2021-12-03 19:20:52 +00:00
|
|
|
days = float(request.values.get("days")) if request.values.get('days') else 0
|
|
|
|
reason = sanitize(request.values.get("reason", ""))[:256]
|
|
|
|
message = request.values.get("reason", "").strip()[:256]
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
if not user: abort(400)
|
|
|
|
|
2021-12-19 23:31:15 +00:00
|
|
|
user.ban(admin=v, reason=reason, days=days)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
if request.values.get("alts", ""):
|
|
|
|
for x in user.alts:
|
|
|
|
if x.admin_level > 0: break
|
2021-12-19 23:31:15 +00:00
|
|
|
user.ban(admin=v, reason=reason, days=days)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
2021-12-19 23:31:47 +00:00
|
|
|
if days > 0:
|
|
|
|
if message: text = f"Your account has been suspended for {days} days for the following reason:\n\n> {message}"
|
|
|
|
else: text = f"Your account has been suspended for {days} days."
|
|
|
|
else:
|
|
|
|
if message: text = f"Your account has been permanently suspended for the following reason:\n\n> {message}"
|
|
|
|
else: text = "Your account has been permanently suspended."
|
|
|
|
|
2021-12-20 20:03:59 +00:00
|
|
|
send_repeatable_notification(user.id, text)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
if days == 0: duration = "permanent"
|
|
|
|
elif days == 1: duration = "1 day"
|
|
|
|
else: duration = f"{days} days"
|
|
|
|
ma=ModAction(
|
|
|
|
kind="ban_user",
|
|
|
|
user_id=v.id,
|
|
|
|
target_user_id=user.id,
|
2021-10-25 18:08:03 +00:00
|
|
|
_note=f'reason: "{reason}", duration: {duration}'
|
2021-10-15 14:08:27 +00:00
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
|
|
|
|
if 'reason' in request.values:
|
|
|
|
if reason.startswith("/post/"):
|
2021-11-25 20:54:46 +00:00
|
|
|
post = int(reason.split("/post/")[1].split(None, 1)[0])
|
|
|
|
post = get_post(post)
|
|
|
|
post.bannedfor = True
|
|
|
|
g.db.add(post)
|
2021-11-25 21:33:00 +00:00
|
|
|
elif reason.startswith("/comment/"):
|
2021-11-25 20:54:46 +00:00
|
|
|
comment = int(reason.split("/comment/")[1].split(None, 1)[0])
|
|
|
|
comment = get_comment(comment)
|
|
|
|
comment.bannedfor = True
|
|
|
|
g.db.add(comment)
|
2021-10-15 14:08:27 +00:00
|
|
|
g.db.commit()
|
|
|
|
|
|
|
|
if 'redir' in request.values: return redirect(user.url)
|
|
|
|
else: return {"message": f"@{user.username} was banned!"}
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/unban_user/<user_id>")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def unban_user(user_id, v):
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
user = g.db.query(User).filter_by(id=user_id).first()
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
if not user:
|
|
|
|
abort(400)
|
|
|
|
|
|
|
|
user.is_banned = 0
|
|
|
|
user.unban_utc = 0
|
2021-10-21 18:06:57 +00:00
|
|
|
user.ban_evade = 0
|
2021-12-20 21:04:15 +00:00
|
|
|
user.ban_reason = None
|
2021-10-15 14:08:27 +00:00
|
|
|
g.db.add(user)
|
|
|
|
|
|
|
|
if request.values.get("alts", ""):
|
|
|
|
for x in user.alts:
|
|
|
|
if x.admin_level == 0:
|
|
|
|
x.is_banned = 0
|
|
|
|
x.unban_utc = 0
|
2021-10-21 18:06:57 +00:00
|
|
|
x.ban_evade = 0
|
2021-10-15 14:08:27 +00:00
|
|
|
g.db.add(x)
|
|
|
|
|
2021-12-20 20:03:59 +00:00
|
|
|
send_repeatable_notification(user.id,
|
2021-10-15 14:08:27 +00:00
|
|
|
"Your account has been reinstated. Please carefully review and abide by the [rules](/post/2510) to ensure that you don't get suspended again.")
|
|
|
|
|
|
|
|
ma=ModAction(
|
|
|
|
kind="unban_user",
|
|
|
|
user_id=v.id,
|
|
|
|
target_user_id=user.id,
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
|
|
|
|
g.db.commit()
|
|
|
|
|
|
|
|
if "@" in request.referrer: return redirect(user.url)
|
|
|
|
else: return {"message": f"@{user.username} was unbanned!"}
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/ban_post/<post_id>")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def ban_post(post_id, v):
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
post = g.db.query(Submission).filter_by(id=post_id).first()
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
if not post:
|
|
|
|
abort(400)
|
|
|
|
|
|
|
|
post.is_banned = True
|
|
|
|
post.is_approved = 0
|
|
|
|
post.stickied = None
|
|
|
|
post.is_pinned = False
|
2021-10-29 02:32:23 +00:00
|
|
|
post.ban_reason = v.username
|
2021-10-15 14:08:27 +00:00
|
|
|
g.db.add(post)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ma=ModAction(
|
|
|
|
kind="ban_post",
|
|
|
|
user_id=v.id,
|
|
|
|
target_submission_id=post.id,
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
|
|
|
|
cache.delete_memoized(frontlist)
|
|
|
|
|
2021-12-12 17:06:48 +00:00
|
|
|
v.coins += 2
|
2021-10-15 14:08:27 +00:00
|
|
|
g.db.add(v)
|
|
|
|
|
|
|
|
g.db.commit()
|
|
|
|
|
|
|
|
return {"message": "Post removed!"}
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/unban_post/<post_id>")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def unban_post(post_id, v):
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
post = g.db.query(Submission).filter_by(id=post_id).first()
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
if not post:
|
|
|
|
abort(400)
|
|
|
|
|
|
|
|
if post.is_banned:
|
|
|
|
ma=ModAction(
|
|
|
|
kind="unban_post",
|
|
|
|
user_id=v.id,
|
|
|
|
target_submission_id=post.id,
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
|
|
|
|
post.is_banned = False
|
|
|
|
post.is_approved = v.id
|
|
|
|
|
|
|
|
g.db.add(post)
|
|
|
|
|
|
|
|
cache.delete_memoized(frontlist)
|
|
|
|
|
2021-12-12 17:06:48 +00:00
|
|
|
v.coins -= 2
|
2021-10-15 14:08:27 +00:00
|
|
|
g.db.add(v)
|
|
|
|
|
|
|
|
g.db.commit()
|
|
|
|
|
|
|
|
return {"message": "Post approved!"}
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/distinguish/<post_id>")
|
|
|
|
@admin_level_required(1)
|
|
|
|
@validate_formkey
|
|
|
|
def api_distinguish_post(post_id, v):
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
post = g.db.query(Submission).filter_by(id=post_id).first()
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
if not post:
|
|
|
|
abort(404)
|
|
|
|
|
|
|
|
if not post.author_id == v.id:
|
|
|
|
abort(403)
|
|
|
|
|
|
|
|
if post.distinguish_level:
|
|
|
|
post.distinguish_level = 0
|
|
|
|
else:
|
|
|
|
post.distinguish_level = v.admin_level
|
|
|
|
|
|
|
|
g.db.add(post)
|
|
|
|
|
|
|
|
g.db.commit()
|
|
|
|
|
|
|
|
return {"message": "Post distinguished!"}
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/sticky/<post_id>")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-12-09 21:21:52 +00:00
|
|
|
@validate_formkey
|
2021-10-15 14:08:27 +00:00
|
|
|
def api_sticky_post(post_id, v):
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
post = g.db.query(Submission).filter_by(id=post_id).first()
|
2021-10-15 14:08:27 +00:00
|
|
|
if post:
|
2021-10-20 21:06:25 +00:00
|
|
|
if post.stickied:
|
2021-12-23 14:55:44 +00:00
|
|
|
if post.stickied.startswith("t:"): return {"error": "Can't unpin temporary pins!"}, 403
|
2021-10-20 21:06:25 +00:00
|
|
|
else: post.stickied = None
|
2021-12-17 07:06:25 +00:00
|
|
|
else:
|
|
|
|
pins = g.db.query(Submission.id).filter(Submission.stickied != None, Submission.is_banned == False).count()
|
2021-12-21 00:23:50 +00:00
|
|
|
if pins > 2:
|
2021-12-21 00:24:18 +00:00
|
|
|
if v.admin_level > 2:
|
|
|
|
t = int(time.time()) + 3600
|
|
|
|
post.stickied = f"t:{t}"
|
|
|
|
else: return {"error": "Can't exceed 3 pinned posts limit!"}, 403
|
2021-12-21 00:23:50 +00:00
|
|
|
else: post.stickied = v.username
|
2021-10-15 14:08:27 +00:00
|
|
|
g.db.add(post)
|
|
|
|
|
|
|
|
ma=ModAction(
|
|
|
|
kind="pin_post" if post.stickied else "unpin_post",
|
|
|
|
user_id=v.id,
|
|
|
|
target_submission_id=post.id
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
|
|
|
|
cache.delete_memoized(frontlist)
|
|
|
|
|
2021-11-15 23:13:29 +00:00
|
|
|
if post.stickied:
|
2021-11-16 21:21:53 +00:00
|
|
|
if v.id != post.author_id:
|
|
|
|
message = f"@{v.username} has pinned your [post](/post/{post_id})!"
|
2021-12-20 20:03:59 +00:00
|
|
|
send_repeatable_notification(post.author_id, message)
|
2021-11-15 23:13:29 +00:00
|
|
|
g.db.commit()
|
|
|
|
return {"message": "Post pinned!"}
|
|
|
|
else:
|
2021-11-16 21:21:53 +00:00
|
|
|
if v.id != post.author_id:
|
|
|
|
message = f"@{v.username} has unpinned your [post](/post/{post_id})!"
|
2021-12-20 20:03:59 +00:00
|
|
|
send_repeatable_notification(post.author_id, message)
|
2021-11-15 23:13:29 +00:00
|
|
|
g.db.commit()
|
|
|
|
return {"message": "Post unpinned!"}
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
@app.post("/ban_comment/<c_id>")
|
|
|
|
@limiter.limit("1/second")
|
2021-12-13 01:23:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-12-09 21:21:52 +00:00
|
|
|
@validate_formkey
|
2021-10-15 14:08:27 +00:00
|
|
|
def api_ban_comment(c_id, v):
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
comment = g.db.query(Comment).filter_by(id=c_id).first()
|
2021-10-15 14:08:27 +00:00
|
|
|
if not comment:
|
|
|
|
abort(404)
|
|
|
|
|
|
|
|
comment.is_banned = True
|
|
|
|
comment.is_approved = 0
|
2021-10-29 02:32:23 +00:00
|
|
|
comment.ban_reason = v.username
|
2021-10-15 14:08:27 +00:00
|
|
|
g.db.add(comment)
|
|
|
|
ma=ModAction(
|
|
|
|
kind="ban_comment",
|
|
|
|
user_id=v.id,
|
|
|
|
target_comment_id=comment.id,
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
g.db.commit()
|
|
|
|
return {"message": "Comment removed!"}
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/unban_comment/<c_id>")
|
|
|
|
@limiter.limit("1/second")
|
2021-12-13 01:23:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-12-09 21:21:52 +00:00
|
|
|
@validate_formkey
|
2021-10-15 14:08:27 +00:00
|
|
|
def api_unban_comment(c_id, v):
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
comment = g.db.query(Comment).filter_by(id=c_id).first()
|
2021-12-01 15:37:36 +00:00
|
|
|
if not comment: abort(404)
|
2021-10-15 14:08:27 +00:00
|
|
|
g.db.add(comment)
|
|
|
|
|
|
|
|
if comment.is_banned:
|
|
|
|
ma=ModAction(
|
|
|
|
kind="unban_comment",
|
|
|
|
user_id=v.id,
|
|
|
|
target_comment_id=comment.id,
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
|
|
|
|
comment.is_banned = False
|
|
|
|
comment.is_approved = v.id
|
|
|
|
|
|
|
|
g.db.commit()
|
|
|
|
|
|
|
|
return {"message": "Comment approved!"}
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/distinguish_comment/<c_id>")
|
2021-12-01 15:37:36 +00:00
|
|
|
@admin_level_required(1)
|
2021-12-09 21:21:52 +00:00
|
|
|
@validate_formkey
|
2021-10-15 14:08:27 +00:00
|
|
|
def admin_distinguish_comment(c_id, v):
|
|
|
|
|
|
|
|
|
|
|
|
comment = get_comment(c_id, v=v)
|
|
|
|
|
2021-12-01 15:37:36 +00:00
|
|
|
if comment.author_id != v.id: abort(403)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
comment.distinguish_level = 0 if comment.distinguish_level else v.admin_level
|
|
|
|
|
|
|
|
g.db.add(comment)
|
2021-12-01 15:37:36 +00:00
|
|
|
html = render_template("comments.html", v=v, comments=[comment])
|
2021-10-15 14:08:27 +00:00
|
|
|
|
2021-12-01 15:37:36 +00:00
|
|
|
html = str(BeautifulSoup(html, features="html.parser").find(id=f"comment-{comment.id}-only"))
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
g.db.commit()
|
|
|
|
|
|
|
|
return html
|
|
|
|
|
|
|
|
@app.get("/admin/dump_cache")
|
2021-11-15 22:13:29 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
def admin_dump_cache(v):
|
|
|
|
cache.clear()
|
|
|
|
return {"message": "Internal cache cleared."}
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/admin/banned_domains/")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
def admin_banned_domains(v):
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
banned_domains = g.db.query(BannedDomain).all()
|
2021-12-20 00:27:25 +00:00
|
|
|
if not v or v.oldsite: template = ''
|
2021-12-19 13:01:28 +00:00
|
|
|
else: template = 'CHRISTMAS/'
|
|
|
|
return render_template(f"{template}admin/banned_domains.html", v=v, banned_domains=banned_domains)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
@app.post("/admin/banned_domains")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def admin_toggle_ban_domain(v):
|
|
|
|
|
|
|
|
domain=request.values.get("domain", "").strip()
|
|
|
|
if not domain: abort(400)
|
|
|
|
|
|
|
|
reason=request.values.get("reason", "").strip()
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
d = g.db.query(BannedDomain).filter_by(domain=domain).first()
|
2021-10-25 18:08:03 +00:00
|
|
|
if d:
|
|
|
|
g.db.delete(d)
|
|
|
|
ma = ModAction(
|
|
|
|
kind="unban_domain",
|
|
|
|
user_id=v.id,
|
|
|
|
_note=domain
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
|
2021-10-15 14:08:27 +00:00
|
|
|
else:
|
|
|
|
d = BannedDomain(domain=domain, reason=reason)
|
|
|
|
g.db.add(d)
|
2021-10-25 18:08:03 +00:00
|
|
|
ma = ModAction(
|
|
|
|
kind="ban_domain",
|
|
|
|
user_id=v.id,
|
|
|
|
_note=f'{domain}, reason: {reason}'
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
2021-10-15 14:08:27 +00:00
|
|
|
|
|
|
|
g.db.commit()
|
|
|
|
|
|
|
|
return redirect("/admin/banned_domains/")
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/admin/nuke_user")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def admin_nuke_user(v):
|
|
|
|
|
|
|
|
user=get_user(request.values.get("user"))
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
for post in g.db.query(Submission).filter_by(author_id=user.id).all():
|
2021-10-15 14:08:27 +00:00
|
|
|
if post.is_banned:
|
|
|
|
continue
|
|
|
|
|
|
|
|
post.is_banned=True
|
|
|
|
g.db.add(post)
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
for comment in g.db.query(Comment).filter_by(author_id=user.id).all():
|
2021-10-15 14:08:27 +00:00
|
|
|
if comment.is_banned:
|
|
|
|
continue
|
|
|
|
|
|
|
|
comment.is_banned=True
|
|
|
|
g.db.add(comment)
|
|
|
|
|
|
|
|
ma=ModAction(
|
|
|
|
kind="nuke_user",
|
|
|
|
user_id=v.id,
|
|
|
|
target_user_id=user.id,
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
|
|
|
|
g.db.commit()
|
|
|
|
|
|
|
|
return redirect(user.url)
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/admin/unnuke_user")
|
|
|
|
@limiter.limit("1/second")
|
2021-11-16 04:18:36 +00:00
|
|
|
@admin_level_required(2)
|
2021-10-15 14:08:27 +00:00
|
|
|
@validate_formkey
|
|
|
|
def admin_nunuke_user(v):
|
|
|
|
|
|
|
|
user=get_user(request.values.get("user"))
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
for post in g.db.query(Submission).filter_by(author_id=user.id).all():
|
2021-10-15 14:08:27 +00:00
|
|
|
if not post.is_banned:
|
|
|
|
continue
|
|
|
|
|
|
|
|
post.is_banned=False
|
|
|
|
g.db.add(post)
|
|
|
|
|
2021-11-06 15:52:48 +00:00
|
|
|
for comment in g.db.query(Comment).filter_by(author_id=user.id).all():
|
2021-10-15 14:08:27 +00:00
|
|
|
if not comment.is_banned:
|
|
|
|
continue
|
|
|
|
|
|
|
|
comment.is_banned=False
|
|
|
|
g.db.add(comment)
|
|
|
|
|
|
|
|
ma=ModAction(
|
|
|
|
kind="unnuke_user",
|
|
|
|
user_id=v.id,
|
|
|
|
target_user_id=user.id,
|
|
|
|
)
|
|
|
|
g.db.add(ma)
|
|
|
|
|
|
|
|
g.db.commit()
|
|
|
|
|
2021-09-24 18:37:44 +00:00
|
|
|
return redirect(user.url)
|