mn
This commit is contained in:
parent
1aece5cc06
commit
743f877663
4 changed files with 13 additions and 10 deletions
|
@ -27,7 +27,7 @@ class Comment(Base):
|
||||||
bannedfor = Column(Boolean)
|
bannedfor = Column(Boolean)
|
||||||
distinguish_level = Column(Integer, default=0)
|
distinguish_level = Column(Integer, default=0)
|
||||||
deleted_utc = Column(Integer, default=0)
|
deleted_utc = Column(Integer, default=0)
|
||||||
is_approved = Column(Integer, default=0)
|
is_approved = Column(Integer, ForeignKey("users.id"))
|
||||||
level = Column(Integer, default=0)
|
level = Column(Integer, default=0)
|
||||||
parent_comment_id = Column(Integer, ForeignKey("comments.id"))
|
parent_comment_id = Column(Integer, ForeignKey("comments.id"))
|
||||||
top_comment_id = Column(Integer)
|
top_comment_id = Column(Integer)
|
||||||
|
|
|
@ -20,7 +20,9 @@ def get_logged_in_user():
|
||||||
if not lo_user: return None
|
if not lo_user: return None
|
||||||
|
|
||||||
nonce = session.get("login_nonce", 0)
|
nonce = session.get("login_nonce", 0)
|
||||||
v = g.db.query(User).filter_by(id=lo_user).one_or_none()
|
id = int(lo_user)
|
||||||
|
v = g.db.query(User).filter_by(id=id).one_or_none()
|
||||||
|
if v.id != id: abort(400)
|
||||||
|
|
||||||
if not v or nonce < v.login_nonce: return None
|
if not v or nonce < v.login_nonce: return None
|
||||||
v.client = None
|
v.client = None
|
||||||
|
|
|
@ -373,7 +373,7 @@ def reported_posts(v):
|
||||||
page = max(1, int(request.values.get("page", 1)))
|
page = max(1, int(request.values.get("page", 1)))
|
||||||
|
|
||||||
listing = g.db.query(Submission).filter_by(
|
listing = g.db.query(Submission).filter_by(
|
||||||
is_approved=0,
|
is_approved=None,
|
||||||
is_banned=False
|
is_banned=False
|
||||||
).join(Submission.reports).order_by(Submission.id.desc()).offset(25 * (page - 1)).limit(26)
|
).join(Submission.reports).order_by(Submission.id.desc()).offset(25 * (page - 1)).limit(26)
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ def reported_comments(v):
|
||||||
|
|
||||||
listing = g.db.query(Comment
|
listing = g.db.query(Comment
|
||||||
).filter_by(
|
).filter_by(
|
||||||
is_approved=0,
|
is_approved=None,
|
||||||
is_banned=False
|
is_banned=False
|
||||||
).join(Comment.reports).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
).join(Comment.reports).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||||
|
|
||||||
|
@ -526,9 +526,9 @@ def badge_grant_post(v):
|
||||||
if url: new_badge.url = url
|
if url: new_badge.url = url
|
||||||
|
|
||||||
g.db.add(new_badge)
|
g.db.add(new_badge)
|
||||||
|
g.db.flush()
|
||||||
|
|
||||||
if v.id != user.id:
|
if v.id != user.id:
|
||||||
g.db.flush()
|
|
||||||
text = f"@{v.username} has given you the following profile badge:\n\n\n\n{new_badge.name}"
|
text = f"@{v.username} has given you the following profile badge:\n\n\n\n{new_badge.name}"
|
||||||
send_notification(user.id, text)
|
send_notification(user.id, text)
|
||||||
|
|
||||||
|
@ -568,8 +568,6 @@ def badge_remove_post(v):
|
||||||
|
|
||||||
badge = user.has_badge(badge_id)
|
badge = user.has_badge(badge_id)
|
||||||
if badge:
|
if badge:
|
||||||
g.db.delete(badge)
|
|
||||||
|
|
||||||
ma = ModAction(
|
ma = ModAction(
|
||||||
kind="badge_remove",
|
kind="badge_remove",
|
||||||
user_id=v.id,
|
user_id=v.id,
|
||||||
|
@ -578,6 +576,8 @@ def badge_remove_post(v):
|
||||||
)
|
)
|
||||||
g.db.add(ma)
|
g.db.add(ma)
|
||||||
|
|
||||||
|
g.db.delete(badge)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
return render_template("admin/badge_remove.html", v=v, badge_types=badges, msg="Badge removed!")
|
return render_template("admin/badge_remove.html", v=v, badge_types=badges, msg="Badge removed!")
|
||||||
|
@ -1112,7 +1112,7 @@ def ban_post(post_id, v):
|
||||||
abort(400)
|
abort(400)
|
||||||
|
|
||||||
post.is_banned = True
|
post.is_banned = True
|
||||||
post.is_approved = 0
|
post.is_approved = None
|
||||||
post.stickied = None
|
post.stickied = None
|
||||||
post.is_pinned = False
|
post.is_pinned = False
|
||||||
post.ban_reason = v.username
|
post.ban_reason = v.username
|
||||||
|
@ -1319,7 +1319,7 @@ def api_ban_comment(c_id, v):
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
comment.is_banned = True
|
comment.is_banned = True
|
||||||
comment.is_approved = 0
|
comment.is_approved = None
|
||||||
comment.ban_reason = v.username
|
comment.ban_reason = v.username
|
||||||
g.db.add(comment)
|
g.db.add(comment)
|
||||||
ma=ModAction(
|
ma=ModAction(
|
||||||
|
|
|
@ -108,6 +108,7 @@ def create_sub2(v):
|
||||||
|
|
||||||
sub = Sub(name=name)
|
sub = Sub(name=name)
|
||||||
g.db.add(sub)
|
g.db.add(sub)
|
||||||
|
g.db.flush()
|
||||||
mod = Mod(user_id=v.id, sub=sub.name, created_utc=int(time.time()))
|
mod = Mod(user_id=v.id, sub=sub.name, created_utc=int(time.time()))
|
||||||
g.db.add(mod)
|
g.db.add(mod)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue