include users who have more than 30 days to be unbanned/unchhuded in /banned and /chuds for accountability

master
Aevann1 2022-11-28 03:32:01 +02:00
parent 8dcd385218
commit d0047dcc5a
7 changed files with 54 additions and 8 deletions

View File

@ -523,9 +523,9 @@ class User(Base):
@property
@lazy
def unban_string(self):
def unban_in(self):
if self.unban_utc == 0:
return "permanently banned"
return "never"
wait = self.unban_utc - int(time.time())
@ -542,9 +542,43 @@ class User(Base):
text = f"{days}d {hours:02d}h {mins:02d}m"
return text
@property
@lazy
def unban_string(self):
text = self.unban_in
if text == "never": return "permanently banned"
return f"Unban in {text}"
@property
@lazy
def unchud_in(self):
if self.agendaposter == 1:
return "never"
wait = self.agendaposter - int(time.time())
if wait < 60:
text = f"{wait}s"
else:
days = wait//(24*60*60)
wait -= days*24*60*60
hours = wait//(60*60)
wait -= hours*60*60
mins = wait//60
text = f"{days}d {hours:02d}h {mins:02d}m"
return text
@property
@lazy
def received_awards(self):

View File

@ -335,7 +335,8 @@ def blocks(v):
@app.get("/banned")
@auth_required
def banned(v:User):
users = g.db.query(User).filter(User.is_banned > 0, User.unban_utc == 0)
after_30_days = int(time.time()) + 86400 * 30
users = g.db.query(User).filter(User.is_banned > 0, or_(User.unban_utc == 0, User.unban_utc > after_30_days))
if not v.can_see_shadowbanned:
users = users.filter(User.shadowbanned == None)
users = users.all()

View File

@ -180,7 +180,8 @@ def grassed(v:User):
@app.get("/chuds")
@auth_required
def chuds(v:User):
users = g.db.query(User).filter(User.agendaposter == 1)
after_30_days = int(time.time()) + 86400 * 30
users = g.db.query(User).filter(or_(User.agendaposter == 1, User.agendaposter > after_30_days))
if not v.can_see_shadowbanned:
users = users.filter(User.shadowbanned == None)
users = users.order_by(User.username).all()

View File

@ -46,9 +46,9 @@
{% if v.admin_level >= PERMS['USER_SHADOWBAN'] %}
<li><a href="/admin/shadowbanned">Shadowbanned Users</a></li>
{% endif %}
<li><a href="/banned">Permabanned Users</a></li>
<li><a href="/banned">Banned Users</a></li>
{% if FEATURES['AWARDS'] -%}
<li><a href="/chuds">Permachudded Users</a></li>
<li><a href="/chuds">Chudded Users</a></li>
<li><a href="/grassed">Currently Grassed Users</a></li>
{%- endif %}
{% if FEATURES['MARSEYBUX'] and (not AEVANN_ID or v.id in (AEVANN_ID, CARP_ID, SNAKES_ID)) -%}

View File

@ -1,6 +1,8 @@
{% extends "settings2.html" %}
{% block pagetitle %}Permabanned Users{% endblock %}
{% block pagetitle %}Banned Users{% endblock %}
{% block content %}
<h5 class="my-4">Users who are permabanned or have more than 30 days to be unbanned</h5>
<div class="overflow-x-auto"><table class="table table-striped mb-5">
<thead class="bg-primary text-white">
<tr>
@ -8,6 +10,7 @@
<th>Name</th>
<th>Ban reason</th>
<th>Banned by</th>
<th>Unban in</th>
</tr>
</thead>
{% for user in users %}
@ -20,6 +23,9 @@
{% include "user_in_table.html" %}
{% endwith %}
</td>
<td>
{{user.unban_in}}
</td>
</tr>
{% endfor %}
</table>

View File

@ -1,17 +1,21 @@
{% extends "settings2.html" %}
{% block pagetitle %}Chuds{% endblock %}
{% block content %}
<h5 class="my-4">Users who are permachudded or have more than 30 days to be unchudded</h5>
<div class="overflow-x-auto"><table class="table table-striped mb-5">
<thead class="bg-primary text-white">
<tr>
<th>#</th>
<th>Name</th>
<th>Unchud in</th>
</tr>
</thead>
{% for user in users %}
<tr>
<td>{{loop.index}}</td>
<td>{% include "user_in_table.html" %}</td>
<td>{{user.unchud_in}}</td>
</tr>
{% endfor %}
</table>

View File

@ -23,7 +23,7 @@
<a class="nav-link{% if request.path == '/log' %} active{% endif %}" href="/log"><i class="fas fa-scroll-old pr-2"></i>Moderation Log</a>
</li>
<li class="nav-item">
<a class="nav-link{% if request.path == '/banned' %} active{% endif %}" href="/banned"><i class="fas fa-user-slash pr-2"></i>Permabanned Users</a>
<a class="nav-link{% if request.path == '/banned' %} active{% endif %}" href="/banned"><i class="fas fa-user-slash pr-2"></i>Banned Users</a>
</li>
{% if v and v.admin_level >= PERMS['USER_BLOCKS_VISIBLE'] -%}
<li class="nav-item">