add user list to admin panel

This commit is contained in:
Yusur 2025-07-07 14:02:45 +02:00
parent 299c29869c
commit 7d8b518c85
4 changed files with 41 additions and 1 deletions

View file

@ -22,7 +22,7 @@ from suou.configparse import ConfigOptions, ConfigValue
from freak.colors import color_themes, theme_classes from freak.colors import color_themes, theme_classes
__version__ = '0.4.0-dev24' __version__ = '0.4.0-dev27'
APP_BASE_DIR = os.path.dirname(os.path.dirname(__file__)) APP_BASE_DIR = os.path.dirname(os.path.dirname(__file__))

View file

@ -8,5 +8,8 @@
<li> <li>
<h2><a href="{{ url_for('admin.strikes') }}">Strikes</a></h2> <h2><a href="{{ url_for('admin.strikes') }}">Strikes</a></h2>
</li> </li>
<li>
<h2><a href="{{ url_for('admin.users') }}">Users</a></h2>
</li>
</ul> </ul>
{% endblock %} {% endblock %}

View file

@ -0,0 +1,29 @@
{% extends "admin/admin_base.html" %}
{% from "macros/feed.html" import stop_scrolling, no_more_scrolling with context %}
{% block content %}
<ul>
{% for u in user_list %}
<li>
<p><a href="{{ u.url() }}">{{ u.handle() }}</a> (#{{ u.id | to_b32l }})
{%- if u.is_administrator %}
<span>(Admin)</span>
{% endif -%}
{% if u == current_user %}
<span>(You)</span>
{% endif -%}
</p>
<ul class="inline">
<li>Age: {{ u.age() }} years old ({{ u.gdpr_birthday.strftime("%B %d, %Y") }})</li>
<li>Registered at: {{ u.joined_at }}</li>
<li>Registered from IP address: {{ u.joined_ip }}</li>
</ul>
</li>
{% endfor %}
{% if user_list.has_next %}
{{ stop_scrolling(user_list.page) }}
{% else %}
{{ no_more_scrolling(user_list.page) }}
{% endif %}
</ul>
{% endblock %}

View file

@ -146,3 +146,11 @@ def strikes():
strike_list = db.paginate(select(UserStrike).order_by(UserStrike.id.desc())) strike_list = db.paginate(select(UserStrike).order_by(UserStrike.id.desc()))
return render_template('admin/admin_strikes.html', return render_template('admin/admin_strikes.html',
strike_list=strike_list, report_reasons=REPORT_REASON_STRINGS) strike_list=strike_list, report_reasons=REPORT_REASON_STRINGS)
@bp.route('/admin/users/')
@admin_required
def users():
user_list = db.paginate(select(User).order_by(User.joined_at.desc()))
return render_template('admin/admin_users.html',
user_list=user_list)