forked from rDrama/rDrama
remove unnecessary property
parent
3300a2c7d4
commit
bf2dbb38a9
|
@ -750,7 +750,7 @@ class User(Base):
|
|||
not_(and_(Comment.sentto != None, Comment.sentto == MODMAIL_ID, User.is_muted))
|
||||
)
|
||||
|
||||
if not self.can_see_shadowbanned:
|
||||
if not self.admin_level >= PERMS['USER_SHADOWBAN']:
|
||||
notifs = notifs.filter(
|
||||
User.shadowbanned == None,
|
||||
Comment.is_banned == False,
|
||||
|
@ -779,7 +779,7 @@ class User(Base):
|
|||
Comment.parent_post == None,
|
||||
)
|
||||
|
||||
if not self.can_see_shadowbanned:
|
||||
if not self.admin_level >= PERMS['USER_SHADOWBAN']:
|
||||
notifs = notifs.join(Comment.author).filter(User.shadowbanned == None)
|
||||
|
||||
return notifs.count()
|
||||
|
@ -953,13 +953,13 @@ class User(Base):
|
|||
@lazy
|
||||
def real_post_count(self, v):
|
||||
if not self.shadowbanned: return self.post_count
|
||||
if v and (v.id == self.id or v.can_see_shadowbanned): return self.post_count
|
||||
if v and (v.id == self.id or v.admin_level >= PERMS['USER_SHADOWBAN']): return self.post_count
|
||||
return 0
|
||||
|
||||
@lazy
|
||||
def real_comment_count(self, v):
|
||||
if not self.shadowbanned: return self.comment_count
|
||||
if v and (v.id == self.id or v.can_see_shadowbanned): return self.comment_count
|
||||
if v and (v.id == self.id or v.admin_level >= PERMS['USER_SHADOWBAN']): return self.comment_count
|
||||
return 0
|
||||
|
||||
@property
|
||||
|
@ -1224,11 +1224,6 @@ class User(Base):
|
|||
return f'((({self.username})))'
|
||||
return self.username
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def can_see_shadowbanned(self):
|
||||
return (self.admin_level >= PERMS['USER_SHADOWBAN'])
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def unmutable(self):
|
||||
|
|
|
@ -134,7 +134,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
|||
word = escape_for_search(word)
|
||||
posts = posts.filter(not_(Post.title.ilike(f'%{word}%')))
|
||||
|
||||
if not v.can_see_shadowbanned:
|
||||
if v.admin_level < PERMS['USER_SHADOWBAN']:
|
||||
posts = posts.join(Post.author).filter(or_(User.id == v.id, User.shadowbanned == None))
|
||||
|
||||
total = posts.count()
|
||||
|
@ -239,7 +239,7 @@ def comment_idlist(v=None, page=1, sort="new", t="day", gt=0, lt=0):
|
|||
if not gt and not lt:
|
||||
comments = apply_time_filter(t, comments, Comment)
|
||||
|
||||
if not v.can_see_shadowbanned:
|
||||
if v.admin_level < PERMS['USER_SHADOWBAN']:
|
||||
comments = comments.join(Comment.author).filter(or_(User.id == v.id, User.shadowbanned == None))
|
||||
|
||||
total = comments.count()
|
||||
|
|
|
@ -301,7 +301,7 @@ def notifications_reddit(v):
|
|||
def notifications(v):
|
||||
page = get_page()
|
||||
|
||||
if not session.get("GLOBAL") and not v.can_see_shadowbanned and not request.values.get('nr'):
|
||||
if not session.get("GLOBAL") and v.admin_level < PERMS['USER_SHADOWBAN'] and not request.values.get('nr'):
|
||||
unread_and_inaccessible = g.db.query(Notification).join(Notification.comment).join(Comment.author).filter(
|
||||
Notification.user_id == v.id,
|
||||
Notification.read == False,
|
||||
|
@ -325,7 +325,7 @@ def notifications(v):
|
|||
not_(and_(Comment.sentto != None, Comment.sentto == MODMAIL_ID, User.is_muted))
|
||||
)
|
||||
|
||||
if not v.can_see_shadowbanned:
|
||||
if v.admin_level < PERMS['USER_SHADOWBAN']:
|
||||
comments = comments.filter(
|
||||
Comment.is_banned == False,
|
||||
Comment.deleted_utc == 0,
|
||||
|
|
|
@ -158,7 +158,7 @@ def searchposts(v):
|
|||
|
||||
posts = apply_time_filter(t, posts, Post)
|
||||
|
||||
if not v.can_see_shadowbanned:
|
||||
if v.admin_level < PERMS['USER_SHADOWBAN']:
|
||||
posts = posts.join(Post.author).filter(or_(User.id == v.id, User.shadowbanned == None))
|
||||
|
||||
total = posts.count()
|
||||
|
@ -270,7 +270,7 @@ def searchcomments(v):
|
|||
except: abort(400)
|
||||
comments = comments.filter(Comment.created_utc < before)
|
||||
|
||||
if not v.can_see_shadowbanned:
|
||||
if v.admin_level < PERMS['USER_SHADOWBAN']:
|
||||
comments = comments.join(Comment.author).filter(or_(User.id == v.id, User.shadowbanned == None))
|
||||
|
||||
total = comments.count()
|
||||
|
@ -362,7 +362,7 @@ def searchmessages(v):
|
|||
|
||||
comments = comments.filter(Comment.sentto == sentto.id)
|
||||
|
||||
if not v.can_see_shadowbanned:
|
||||
if v.admin_level < PERMS['USER_SHADOWBAN']:
|
||||
comments = comments.join(Comment.author).filter(or_(User.id == v.id, User.shadowbanned == None))
|
||||
|
||||
total = comments.count()
|
||||
|
|
|
@ -194,7 +194,7 @@ def log(v):
|
|||
|
||||
kind = request.values.get("kind")
|
||||
|
||||
if v.can_see_shadowbanned:
|
||||
if v.admin_level >= PERMS['USER_SHADOWBAN']:
|
||||
if v.admin_level >= PERMS['PROGSTACK']:
|
||||
types = MODACTION_TYPES
|
||||
else:
|
||||
|
@ -207,7 +207,7 @@ def log(v):
|
|||
total = 0
|
||||
else:
|
||||
actions = g.db.query(ModAction)
|
||||
if not v.can_see_shadowbanned:
|
||||
if v.admin_level < PERMS['USER_SHADOWBAN']:
|
||||
actions = actions.filter(ModAction.kind.notin_(MODACTION_PRIVILEGED_TYPES))
|
||||
if v.admin_level < PERMS['PROGSTACK']:
|
||||
actions = actions.filter(ModAction.kind.notin_(MODACTION_PRIVILEGED__TYPES))
|
||||
|
@ -236,12 +236,12 @@ def log_item(id, v):
|
|||
|
||||
if not action: abort(404)
|
||||
|
||||
if action.kind in MODACTION_PRIVILEGED_TYPES and not v.can_see_shadowbanned:
|
||||
if action.kind in MODACTION_PRIVILEGED_TYPES and v.admin_level < PERMS['USER_SHADOWBAN']:
|
||||
abort(404)
|
||||
|
||||
admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level >= PERMS['ADMIN_MOP_VISIBLE'])]
|
||||
|
||||
if v.can_see_shadowbanned:
|
||||
if v.admin_level >= PERMS['USER_SHADOWBAN']:
|
||||
if v.admin_level >= PERMS['PROGSTACK']:
|
||||
types = MODACTION_TYPES
|
||||
else:
|
||||
|
|
|
@ -835,7 +835,7 @@ def u_username_wall(v, username):
|
|||
|
||||
is_following = v and u.has_follower(v)
|
||||
|
||||
if v and v.id != u.id and not v.can_see_shadowbanned and not session.get("GLOBAL"):
|
||||
if v and v.id != u.id and v.admin_level < PERMS['USER_SHADOWBAN'] and not session.get("GLOBAL"):
|
||||
gevent.spawn(_add_profile_view, v.id, u.id)
|
||||
|
||||
page = get_page()
|
||||
|
@ -853,7 +853,7 @@ def u_username_wall(v, username):
|
|||
Comment.deleted_utc == 0
|
||||
)
|
||||
|
||||
if not v.can_see_shadowbanned:
|
||||
if v.admin_level < PERMS['USER_SHADOWBAN']:
|
||||
comments = comments.join(Comment.author).filter(or_(User.id == v.id, User.shadowbanned == None))
|
||||
|
||||
total = comments.count()
|
||||
|
@ -885,7 +885,7 @@ def u_username_wall_comment(v, username, cid):
|
|||
|
||||
is_following = v and u.has_follower(v)
|
||||
|
||||
if v and v.id != u.id and not v.can_see_shadowbanned and not session.get("GLOBAL"):
|
||||
if v and v.id != u.id and v.admin_level < PERMS['USER_SHADOWBAN'] and not session.get("GLOBAL"):
|
||||
gevent.spawn(_add_profile_view, v.id, u.id)
|
||||
|
||||
if v and request.values.get("read"):
|
||||
|
@ -930,7 +930,7 @@ def u_username(v, username):
|
|||
abort(403, f"@{u.username}'s userpage is private")
|
||||
return render_template("userpage/private.html", u=u, v=v, is_following=is_following), 403
|
||||
|
||||
if v and v.id != u.id and not v.can_see_shadowbanned and not session.get("GLOBAL"):
|
||||
if v and v.id != u.id and v.admin_level < PERMS['USER_SHADOWBAN'] and not session.get("GLOBAL"):
|
||||
gevent.spawn(_add_profile_view, v.id, u.id)
|
||||
|
||||
sort = request.values.get("sort", "new")
|
||||
|
@ -997,7 +997,7 @@ def u_username_comments(username, v):
|
|||
abort(403, f"@{u.username}'s userpage is private")
|
||||
return render_template("userpage/private.html", u=u, v=v, is_following=is_following), 403
|
||||
|
||||
if v and v.id != u.id and not v.can_see_shadowbanned and not session.get("GLOBAL"):
|
||||
if v and v.id != u.id and v.admin_level < PERMS['USER_SHADOWBAN'] and not session.get("GLOBAL"):
|
||||
gevent.spawn(_add_profile_view, v.id, u.id)
|
||||
|
||||
page = get_page()
|
||||
|
|
|
@ -203,7 +203,7 @@ def vote_info_get(v, link):
|
|||
if obj.ghost and v.admin_level < PERMS['SEE_GHOST_VOTES']:
|
||||
abort(403)
|
||||
|
||||
if obj.author.shadowbanned and not (v and v.can_see_shadowbanned):
|
||||
if obj.author.shadowbanned and not (v and v.admin_level >= PERMS['USER_SHADOWBAN']):
|
||||
abort(500)
|
||||
|
||||
if isinstance(obj, Post):
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
|
||||
<h4>Users</h4>
|
||||
<ul>
|
||||
{% if v.can_see_shadowbanned %}
|
||||
{% if v.admin_level >= PERMS['USER_SHADOWBAN'] %}
|
||||
<li><a href="/admin/shadowbanned">Shadowbanned Users</a></li>
|
||||
{% endif %}
|
||||
<li><a href="/banned">Banned Users</a></li>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
{% set count=alts|length %}
|
||||
<section class="userinfo-section">
|
||||
<p><a href="/@{{u.username}}">@{{u.username}}</a> created their account {{u.created_utc|timestamp}} and has {{count}} known alt{{macros.plural(count)}}.<br>
|
||||
They are {% if not u.is_permabanned %}not {% endif %}permanently banned{% if v.can_see_shadowbanned %} and they are {% if not u.shadowbanned %}not {% endif %}shadowbanned{% endif %}.</p>
|
||||
They are {% if not u.is_permabanned %}not {% endif %}permanently banned{% if v.admin_level >= PERMS['USER_SHADOWBAN'] %} and they are {% if not u.shadowbanned %}not {% endif %}shadowbanned{% endif %}.</p>
|
||||
</section>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table table-striped mb-5">
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{% if user.shadowbanned and v and v.can_see_shadowbanned %}
|
||||
{% if user.shadowbanned and v and v.admin_level >= PERMS['USER_SHADOWBAN'] %}
|
||||
<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title='Shadowbanned by @{{user.shadowbanner}} for "{{user.ban_reason}}"' data-bs-html="true"></i>
|
||||
{% endif %}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
{% endif %}
|
||||
</h5>
|
||||
{% endif %}
|
||||
{% if v and v.can_see_shadowbanned and u.shadowbanned %}
|
||||
{% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and u.shadowbanned %}
|
||||
<h5 class="text-primary" id="profile-{{deviceType}}--shadowbanned">SHADOWBANNED USER:
|
||||
{{u.ban_reason | safe}}
|
||||
|
||||
|
@ -66,7 +66,7 @@
|
|||
|
||||
<button type="button" id="unban-{{deviceType}}" class="mt-1 {% if not u.is_suspended %}d-none{% endif %} btn btn-success" data-nonce="{{g.nonce}}" data-onclick="unchud_or_unban(this,'/unban_user/{{u.id}}')">Unban user</button>
|
||||
{% endif %}
|
||||
{% if v.can_see_shadowbanned %}
|
||||
{% if v.admin_level >= PERMS['USER_SHADOWBAN'] %}
|
||||
<form id="shadowban-{{deviceType}}" class="my-3 {% if u.shadowbanned %}d-none{% endif %}" action="/shadowban/{{u.id}}" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHRSwitch(this)">
|
||||
<input hidden name="formkey" value="{{v|formkey}}">
|
||||
<input autocomplete="off" style="font-size:11px" type="text" class="form-control" maxlength="256" name="reason" placeholder="Shadowban Reason" data-nonce="{{g.nonce}}" data-undisable_element="user-shadowban-submit-{{deviceType}}" required>
|
||||
|
|
Loading…
Reference in New Issue