show who exiled the user in the icon
parent
670455e7ff
commit
67f968d04d
|
@ -394,11 +394,12 @@ class User(Base):
|
|||
return bool(g.db.query(Mod.user_id).filter_by(user_id=self.id, sub=sub).one_or_none())
|
||||
|
||||
@lazy
|
||||
def exiled_from(self, sub):
|
||||
try:
|
||||
return any(map(lambda x: x.sub == sub, self.sub_exiles))
|
||||
except:
|
||||
return bool(g.db.query(Exile.user_id).filter_by(user_id=self.id, sub=sub).one_or_none())
|
||||
def exiler_username(self, sub):
|
||||
exile = g.db.query(Exile).options(load_only(Exile.exiler_id)).filter_by(user_id=self.id, sub=sub).one_or_none()
|
||||
if exile:
|
||||
return exile.exiler.username
|
||||
else:
|
||||
return None
|
||||
|
||||
@property
|
||||
@lazy
|
||||
|
|
|
@ -146,7 +146,7 @@ def comment(v):
|
|||
|
||||
if posting_to_post:
|
||||
sub = post_target.sub
|
||||
if sub and v.exiled_from(sub): abort(403, f"You're exiled from /h/{sub}")
|
||||
if sub and v.exiler_username(sub): abort(403, f"You're exiled from /h/{sub}")
|
||||
if sub in {'furry','vampire','racist','femboy','edgy'} and not v.client and not v.house.lower().startswith(sub):
|
||||
abort(403, f"You need to be a member of House {sub.capitalize()} to comment in /h/{sub}")
|
||||
|
||||
|
|
|
@ -451,7 +451,7 @@ def submit_post(v, sub=None):
|
|||
sub = g.db.query(Sub.name).filter_by(name=sname).one_or_none()
|
||||
if not sub: abort(400, f"/h/{sname} not found!")
|
||||
sub = sub[0]
|
||||
if v.exiled_from(sub): abort(400, f"You're exiled from /h/{sub}")
|
||||
if v.exiler_username(sub): abort(400, f"You're exiled from /h/{sub}")
|
||||
else: sub = None
|
||||
|
||||
if not sub and HOLE_REQUIRED:
|
||||
|
|
|
@ -180,7 +180,7 @@ def move_post(post, v, reason):
|
|||
|
||||
if sub_from == sub_to: abort(409, f"Post is already in {sub_to_in_notif}")
|
||||
|
||||
if post.author.exiled_from(sub_to):
|
||||
if post.author.exiler_username(sub_to):
|
||||
abort(403, f"User is exiled from this {HOLE_NAME}!")
|
||||
|
||||
if sub_to == 'changelog':
|
||||
|
|
|
@ -25,7 +25,7 @@ def exile_post(v, pid):
|
|||
|
||||
if u.mods(sub): abort(403)
|
||||
|
||||
if not u.exiled_from(sub):
|
||||
if not u.exiler_username(sub):
|
||||
exile = Exile(user_id=u.id, sub=sub, exiler_id=v.id)
|
||||
g.db.add(exile)
|
||||
|
||||
|
@ -60,7 +60,7 @@ def exile_comment(v, cid):
|
|||
|
||||
if u.mods(sub): abort(403)
|
||||
|
||||
if not u.exiled_from(sub):
|
||||
if not u.exiler_username(sub):
|
||||
exile = Exile(user_id=u.id, sub=sub, exiler_id=v.id)
|
||||
g.db.add(exile)
|
||||
|
||||
|
@ -89,7 +89,7 @@ def unexile(v, sub, uid):
|
|||
if not v.mods(sub): abort(403)
|
||||
if v.shadowbanned: return redirect(f'/h/{sub}/exilees')
|
||||
|
||||
if u.exiled_from(sub):
|
||||
if u.exiler_username(sub):
|
||||
exile = g.db.query(Exile).filter_by(user_id=u.id, sub=sub).one_or_none()
|
||||
g.db.delete(exile)
|
||||
|
||||
|
|
|
@ -130,8 +130,8 @@
|
|||
|
||||
{% if c.parent_post %}
|
||||
{% set sub = c.post.sub %}
|
||||
{% if sub and c.author.exiled_from(sub) %}
|
||||
<a><i class="fas fa-campfire text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="User has been exiled from /h/{{sub}}"></i></a>
|
||||
{% if sub and c.author.exiler_username(sub) %}
|
||||
<a><i class="fas fa-campfire text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="User has been exiled from /h/{{sub}} by @{{c.author.exiler_username(sub)}}"></i></a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
|
@ -466,8 +466,8 @@
|
|||
{% if c.parent_post %}
|
||||
{% set sub = c.post.sub %}
|
||||
{% if sub and v.mods(sub) and not c.author.mods(sub) %}
|
||||
<button type="button" id="exile-{{c.id}}" class="d-none {% if not c.author.exiled_from(sub) %}d-md-block{% endif %} dropdown-item list-inline-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/exile/comment/{{c.id}}','exile-{{c.id}}','unexile-{{c.id}}','d-none')"><i class="fas fa-campfire text-danger fa-fw"></i>Exile user</button>
|
||||
<button type="button" id="unexile-{{c.id}}" class="d-none {% if c.author.exiled_from(sub) %}d-md-block{% endif %} dropdown-item list-inline-item text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/h/{{sub}}/unexile/{{c.author_id}}','exile-{{c.id}}','unexile-{{c.id}}','d-none')"><i class="fas fa-campfire text-success fa-fw"></i>Unexile user</button>
|
||||
<button type="button" id="exile-{{c.id}}" class="d-none {% if not c.author.exiler_username(sub) %}d-md-block{% endif %} dropdown-item list-inline-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/exile/comment/{{c.id}}','exile-{{c.id}}','unexile-{{c.id}}','d-none')"><i class="fas fa-campfire text-danger fa-fw"></i>Exile user</button>
|
||||
<button type="button" id="unexile-{{c.id}}" class="d-none {% if c.author.exiler_username(sub) %}d-md-block{% endif %} dropdown-item list-inline-item text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/h/{{sub}}/unexile/{{c.author_id}}','exile-{{c.id}}','unexile-{{c.id}}','d-none')"><i class="fas fa-campfire text-success fa-fw"></i>Unexile user</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
|
@ -642,8 +642,8 @@
|
|||
{% if c.parent_post %}
|
||||
{% set sub = c.post.sub %}
|
||||
{% if sub and v.mods(sub) and not c.author.mods(sub) %}
|
||||
<button type="button" data-bs-dismiss="modal" id="exile2-{{c.id}}" class="{% if c.author.exiled_from(sub) %}d-none{% endif %} list-group-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/exile/comment/{{c.id}}','exile2-{{c.id}}','unexile2-{{c.id}}','d-none')"><i class="fas fa-campfire text-danger mr-2"></i>Exile user</button>
|
||||
<button type="button" data-bs-dismiss="modal" id="unexile2-{{c.id}}" class="{% if not c.author.exiled_from(sub) %}d-none{% endif %} list-group-item text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/h/{{sub}}/unexile/{{c.author_id}}','exile2-{{c.id}}','unexile2-{{c.id}}','d-none')"><i class="fas fa-campfire text-success mr-2"></i>Unexile user</button>
|
||||
<button type="button" data-bs-dismiss="modal" id="exile2-{{c.id}}" class="{% if c.author.exiler_username(sub) %}d-none{% endif %} list-group-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/exile/comment/{{c.id}}','exile2-{{c.id}}','unexile2-{{c.id}}','d-none')"><i class="fas fa-campfire text-danger mr-2"></i>Exile user</button>
|
||||
<button type="button" data-bs-dismiss="modal" id="unexile2-{{c.id}}" class="{% if not c.author.exiler_username(sub) %}d-none{% endif %} list-group-item text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/h/{{sub}}/unexile/{{c.author_id}}','exile2-{{c.id}}','unexile2-{{c.id}}','d-none')"><i class="fas fa-campfire text-success mr-2"></i>Unexile user</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
|
|
@ -71,8 +71,8 @@
|
|||
{% if p.sub and v.mods(p.sub) %}
|
||||
<button type="button" class="dropdown-item list-inline-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/kick/{{p.id}}')"><i class="fas fa-sign-out text-danger"></i>Kick</button>
|
||||
{% if not p.author.mods(p.sub) %}
|
||||
<button type="button" id="exile-{{p.id}}" class="{% if p.author.exiled_from(p.sub) %}d-none{% endif %} dropdown-item list-inline-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/exile/post/{{p.id}}','exile-{{p.id}}','unexile-{{p.id}}','d-none')"><i class="fas fa-campfire text-danger"></i>Exile user</button>
|
||||
<button type="button" id="unexile-{{p.id}}" class="{% if not p.author.exiled_from(p.sub) %}d-none{% endif %} dropdown-item list-inline-item text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/h/{{sub}}/unexile/{{p.author_id}}','exile-{{p.id}}','unexile-{{p.id}}','d-none')"><i class="fas fa-campfire text-success"></i>Unexile user</button>
|
||||
<button type="button" id="exile-{{p.id}}" class="{% if p.author.exiler_username(p.sub) %}d-none{% endif %} dropdown-item list-inline-item text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/exile/post/{{p.id}}','exile-{{p.id}}','unexile-{{p.id}}','d-none')"><i class="fas fa-campfire text-danger"></i>Exile user</button>
|
||||
<button type="button" id="unexile-{{p.id}}" class="{% if not p.author.exiler_username(p.sub) %}d-none{% endif %} dropdown-item list-inline-item text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/h/{{sub}}/unexile/{{p.author_id}}','exile-{{p.id}}','unexile-{{p.id}}','d-none')"><i class="fas fa-campfire text-success"></i>Unexile user</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if FEATURES['NSFW_MARKING'] and (v.id==p.author_id or v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or (p.sub and v.mods(p.sub))) %}
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
<button type="button" data-bs-dismiss="modal" class="nobackground btn btn-link btn-block btn-lg text-left text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/kick/{{p.id}}')"><i class="fas fa-sign-out text-danger text-center mr-2"></i>Kick</button>
|
||||
|
||||
{% if not p.author.mods(p.sub) %}
|
||||
<button type="button" data-bs-dismiss="modal" id="exile2" class="{% if p.author.exiled_from(p.sub) %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/exile/post/{{p.id}}','exile2','unexile2','d-none')"><i class="fas fa-campfire mr-2 text-danger"></i>Exile user</button>
|
||||
<button type="button" data-bs-dismiss="modal" id="unexile2" class="{% if not p.author.exiled_from(p.sub) %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/h/{{sub}}/unexile/{{p.author_id}}','exile2','unexile2','d-none')"><i class="fas fa-campfire mr-2 text-success"></i>Unexile user</button>
|
||||
<button type="button" data-bs-dismiss="modal" id="exile2" class="{% if p.author.exiler_username(p.sub) %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-danger" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/exile/post/{{p.id}}','exile2','unexile2','d-none')"><i class="fas fa-campfire mr-2 text-danger"></i>Exile user</button>
|
||||
<button type="button" data-bs-dismiss="modal" id="unexile2" class="{% if not p.author.exiler_username(p.sub) %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/h/{{sub}}/unexile/{{p.author_id}}','exile2','unexile2','d-none')"><i class="fas fa-campfire mr-2 text-success"></i>Unexile user</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
{%- endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if p.sub and p.author.exiled_from(p.sub) %}
|
||||
<a><i class="fas fa-campfire text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="User has been exiled from {% if not HOLE_STYLE_FLAIR %}/h/{% endif %}{{p.sub}}"></i></a>
|
||||
{% if p.sub and p.author.exiler_username(p.sub) %}
|
||||
<a><i class="fas fa-campfire text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="User has been exiled from /h/{{p.sub}} by @{{p.author.exiler_username(p.sub)}}"></i></a>
|
||||
{% endif %}
|
||||
|
||||
{% if p.bannedfor %}
|
||||
|
|
Loading…
Reference in New Issue