fix flag filtering
parent
20a659da73
commit
ee11a28636
|
@ -391,10 +391,14 @@ class Comment(Base):
|
|||
@lazy
|
||||
def is_op(self): return self.author_id==self.post.author_id
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def active_flags(self): return len(self.flags)
|
||||
|
||||
def filtered_flags(self, v):
|
||||
return [f for f in self.flags if (v and v.shadowbanned) or not f.user.shadowbanned]
|
||||
|
||||
@lazy
|
||||
def active_flags(self, v):
|
||||
return len(self.filtered_flags(v))
|
||||
|
||||
@lazy
|
||||
def wordle_html(self, v):
|
||||
if not self.wordle_result: return ''
|
||||
|
|
|
@ -401,7 +401,10 @@ class Submission(Base):
|
|||
return True
|
||||
return False
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def active_flags(self):
|
||||
return len(self.flags)
|
||||
def filtered_flags(self, v):
|
||||
return [f for f in self.flags if (v and v.shadowbanned) or not f.user.shadowbanned]
|
||||
|
||||
@lazy
|
||||
def active_flags(self, v):
|
||||
return len(self.filtered_flags(v))
|
|
@ -177,7 +177,7 @@
|
|||
{% if c.bannedfor %}
|
||||
<i class="fas fa-hammer-crash text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="User was banned for this comment for {{c.bannedfor}}"></i>
|
||||
{% endif %}
|
||||
{% if c.active_flags and (v and v.admin_level >= PERMS['FLAGS_VISIBLE']) %}<a class="btn btn-primary" style="padding:1px 5px; font-size:10px"role="button" onclick="document.getElementById('flaggers-{{c.id}}').classList.toggle('d-none')">{{c.active_flags}} Report{{ help.plural(c.active_flags) }}</a>{% endif %}
|
||||
{% if c.active_flags(v) and (v and v.admin_level >= PERMS['FLAGS_VISIBLE']) %}<a class="btn btn-primary" style="padding:1px 5px; font-size:10px"role="button" onclick="document.getElementById('flaggers-{{c.id}}').classList.toggle('d-none')">{{c.active_flags(v)}} Report{{ help.plural(c.active_flags(v)) }}</a>{% endif %}
|
||||
{% if c.over_18 %}<span class="badge badge-danger text-small-extra mr-1">+18</span>{% endif %}
|
||||
{% if v and v.admin_level > 1 and c.author.shadowbanned %}<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Shadowbanned by @{{c.author.shadowbanned}}"></i>{% endif %}
|
||||
{% if c.stickied %}
|
||||
|
@ -251,15 +251,13 @@
|
|||
{{c.wordle_html(v) | safe}}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if c.active_flags and (v and v.admin_level >= PERMS['FLAGS_VISIBLE']) %}
|
||||
{% if c.active_flags(v) and (v and v.admin_level >= PERMS['FLAGS_VISIBLE']) %}
|
||||
<div id="flaggers-{{c.id}}" class="flaggers d-none">
|
||||
<strong><i class="far fa-fw fa-flag"></i> Reported by:</strong>
|
||||
<pre></pre>
|
||||
<ul style="padding-left:20px; margin-bottom: 0;word-wrap:break-word">
|
||||
{% for f in c.flags %}
|
||||
{% if (v and v.shadowbanned) or not f.user.shadowbanned %}
|
||||
<li>{% if v and v.admin_level >= PERMS['FLAGS_VISIBLE_REPORTER'] %}{% if not c.ghost %}<a style="font-weight:bold" href="{{f.user.url}}">{{f.user.username}}</a>{% else %}👻{% endif %}{% else %}User{% endif %}{% if f.reason %}: {{f.realreason(v) | safe}}{% endif %} {% if v and v.admin_level >= PERMS['FLAGS_REMOVE'] %}<a role="button" onclick="post_toast(this,'/del_report/comment/{{f.comment_id}}/{{f.user_id}}')">[remove]</a>{% endif %}</li>
|
||||
{% endif %}
|
||||
{% for f in c.filtered_flags(v) %}
|
||||
<li>{% if v and v.admin_level >= PERMS['FLAGS_VISIBLE_REPORTER'] %}{% if not c.ghost %}<a style="font-weight:bold" href="{{f.user.url}}">{{f.user.username}}</a>{% else %}👻{% endif %}{% else %}User{% endif %}{% if f.reason %}: {{f.realreason(v) | safe}}{% endif %} {% if v and v.admin_level >= PERMS['FLAGS_REMOVE'] %}<a role="button" onclick="post_toast(this,'/del_report/comment/{{f.comment_id}}/{{f.user_id}}')">[remove]</a>{% endif %}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -658,7 +658,7 @@
|
|||
{% if p.is_bot %} <i class="fas fa-robot text-info" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Bot"></i>{% endif %}
|
||||
{% if p.over_18 %}<span class="badge badge-danger text-small-extra mr-1">+18</span>{% endif %}
|
||||
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">Draft</span>{% endif %}
|
||||
{% if p.active_flags and (v and v.admin_level >= PERMS['FLAGS_VISIBLE']) %}<a class="btn btn-primary" role="button" style="padding:1px 5px; font-size:10px"onclick="document.getElementById('flaggers').classList.toggle('d-none')">{{p.active_flags}} Report{{ help.plural(p.active_flags) }}</a>{% endif %}
|
||||
{% if p.active_flags(v) and (v and v.admin_level >= PERMS['FLAGS_VISIBLE']) %}<a class="btn btn-primary" role="button" style="padding:1px 5px; font-size:10px"onclick="document.getElementById('flaggers').classList.toggle('d-none')">{{p.active_flags(v)}} Report{{ help.plural(p.active_flags(v)) }}</a>{% endif %}
|
||||
|
||||
{% if p.ghost %}
|
||||
<span {% if p.distinguish_level %}class="mod"{% endif %}>👻</span>
|
||||
|
@ -691,15 +691,13 @@
|
|||
{% endif %}
|
||||
{{p.views}} thread views
|
||||
</div>
|
||||
{% if p.active_flags and (v and v.admin_level >= PERMS['FLAGS_VISIBLE']) %}
|
||||
{% if p.active_flags(v) and (v and v.admin_level >= PERMS['FLAGS_VISIBLE']) %}
|
||||
<div id="flaggers" class="flaggers d-none">
|
||||
<strong><i class="far fa-fw fa-flag"></i> Reported by:</strong>
|
||||
<pre></pre>
|
||||
<ul style="padding-left:20px; margin-bottom: 0;word-wrap:break-word">
|
||||
{% for f in p.flags %}
|
||||
{% if (v and v.shadowbanned) or not f.user.shadowbanned %}
|
||||
<li>{% if v and v.admin_level >= PERMS['FLAGS_VISIBLE_REPORTER'] %}<a style="font-weight:bold" href="{{f.user.url}}">{{f.user.username}}</a>{% else %}User{% endif %}{% if f.reason %}: {{f.realreason(v) | safe}}{% endif %} {% if v and v.admin_level >= PERMS['FLAGS_REMOVE'] %}<a role="button" onclick="post_toast(this,'/del_report/post/{{f.post_id}}/{{f.user_id}}')">[remove]</a>{% endif %}</li>
|
||||
{% endif %}
|
||||
{% for f in p.filtered_flags(v) %}
|
||||
<li>{% if v and v.admin_level >= PERMS['FLAGS_VISIBLE_REPORTER'] %}<a style="font-weight:bold" href="{{f.user.url}}">{{f.user.username}}</a>{% else %}User{% endif %}{% if f.reason %}: {{f.realreason(v) | safe}}{% endif %} {% if v and v.admin_level >= PERMS['FLAGS_REMOVE'] %}<a role="button" onclick="post_toast(this,'/del_report/post/{{f.post_id}}/{{f.user_id}}')">[remove]</a>{% endif %}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -67,15 +67,13 @@
|
|||
|
||||
{% set v_forbid_deleted = (p.deleted_utc != 0 or p.is_banned) and not (v and v.admin_level >= 2) and not (v and v.id == p.author_id) %}
|
||||
|
||||
{% if p.active_flags and (v and v.admin_level >= PERMS['FLAGS_VISIBLE']) %}
|
||||
{% if p.active_flags(v) and (v and v.admin_level >= PERMS['FLAGS_VISIBLE']) %}
|
||||
<div id="flaggers-{{p.id}}" class="flaggers d-none">
|
||||
<strong><i class="far fa-fw fa-flag"></i> Reported by:</strong>
|
||||
<pre></pre>
|
||||
<ul style="padding-left:20px; margin-bottom: 0;word-wrap:break-word">
|
||||
{% for f in p.flags %}
|
||||
{% if (v and v.shadowbanned) or not f.user.shadowbanned %}
|
||||
<li>{% if v and v.admin_level >= PERMS['FLAGS_VISIBLE_REPORTER'] %}<a style="font-weight:bold" href="{{f.user.url}}">{{f.user.username}}</a>{% else %}User{% endif %}{% if f.reason %}: {{f.realreason(v) | safe}}{% endif %} {% if v and v.admin_level >= PERMS['FLAGS_REMOVE'] %}<a role="button" onclick="post_toast(this,'/del_report/post/{{f.post_id}}/{{f.user_id}}')">[remove]</a>{% endif %}</li>
|
||||
{% endif %}
|
||||
{% for f in p.filtered_flags(v) %}
|
||||
<li>{% if v and v.admin_level >= PERMS['FLAGS_VISIBLE_REPORTER'] %}<a style="font-weight:bold" href="{{f.user.url}}">{{f.user.username}}</a>{% else %}User{% endif %}{% if f.reason %}: {{f.realreason(v) | safe}}{% endif %} {% if v and v.admin_level >= PERMS['FLAGS_REMOVE'] %}<a role="button" onclick="post_toast(this,'/del_report/post/{{f.post_id}}/{{f.user_id}}')">[remove]</a>{% endif %}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -191,7 +189,7 @@
|
|||
{% if p.is_blocking %}<i class="fas fa-user-minus text-warning" data-bs-toggle="tooltip" data-bs-placement="bottom" title="You're blocking this user, but you can see this post because you're an admin."></i>{% endif %}
|
||||
{% if p.is_blocked %}<i class="fas fa-user-minus text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="This user is blocking you."></i>{% endif %}
|
||||
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">Draft</span>{% endif %}
|
||||
{% if p.active_flags and (v and v.admin_level >= PERMS['FLAGS_VISIBLE']) %}<a class="btn btn-primary" role="button" style="padding:1px 5px; font-size:10px"onclick="document.getElementById('flaggers-{{p.id}}').classList.toggle('d-none')">{{p.active_flags}} Report{{ help.plural(p.active_flags) }}</a>{% endif %}
|
||||
{% if p.active_flags(v) and (v and v.admin_level >= PERMS['FLAGS_VISIBLE']) %}<a class="btn btn-primary" role="button" style="padding:1px 5px; font-size:10px"onclick="document.getElementById('flaggers-{{p.id}}').classList.toggle('d-none')">{{p.active_flags(v)}} Report{{ help.plural(p.active_flags(v)) }}</a>{% endif %}
|
||||
|
||||
{% if p.ghost %}
|
||||
<span {% if p.distinguish_level %}class="mod"{% endif %}>👻</span>
|
||||
|
|
Loading…
Reference in New Issue