forked from rDrama/rDrama
trying to fix exiling
parent
b71d55cfb9
commit
a36c0f9dd3
|
@ -169,7 +169,7 @@ class User(Base):
|
|||
|
||||
@lazy
|
||||
def exiled_from(self, sub):
|
||||
return self.admin_level < 2 and bool(g.db.query(Exile.user_id).filter_by(user_id=self.id, sub=sub).one_or_none())
|
||||
return bool(g.db.query(Exile.user_id).filter_by(user_id=self.id, sub=sub).one_or_none())
|
||||
|
||||
@property
|
||||
@lazy
|
||||
|
|
|
@ -45,6 +45,10 @@ def flag_post(pid, v):
|
|||
sub_to = sub_to.name if sub_to else None
|
||||
|
||||
if sub_from == sub_to: abort(400)
|
||||
|
||||
if post.author.exiled_from(sub_to):
|
||||
return {"error": f"User is exiled from this {HOLE_NAME}!"}
|
||||
|
||||
post.sub = sub_to
|
||||
g.db.add(post)
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ def exile_post(v, pid):
|
|||
|
||||
if u.mods(sub): abort(403)
|
||||
|
||||
if u.admin_level < 2 and not u.exiled_from(sub):
|
||||
if not u.exiled_from(sub):
|
||||
exile = Exile(user_id=u.id, sub=sub, exiler_id=v.id)
|
||||
g.db.add(exile)
|
||||
|
||||
|
@ -50,7 +50,7 @@ def exile_comment(v, cid):
|
|||
|
||||
if u.mods(sub): abort(403)
|
||||
|
||||
if u.admin_level < 2 and not u.exiled_from(sub):
|
||||
if not u.exiled_from(sub):
|
||||
exile = Exile(user_id=u.id, sub=sub, exiler_id=v.id)
|
||||
g.db.add(exile)
|
||||
|
||||
|
|
Loading…
Reference in New Issue