diff options
| author | rebecca <ubq323@ubq323.website> | 2026-10-30 23:23:29 +0000 |
|---|---|---|
| committer | rebecca <ubq323@ubq323.website> | 2026-10-30 23:23:29 +0000 |
| commit | e5ffd464edfaf5d1644bd20f0299d15674bde50d (patch) | |
| tree | 85af952d9cd811c6523a8ea18a783e7a4b133b57 | |
| parent | 2e5483b93642af9246bb08b5abbeed47498e43f4 (diff) | |
admin: make user list more useful
| -rw-r--r-- | apioforum/admin.py | 5 | ||||
| -rw-r--r-- | apioforum/templates/admin/users.html | 20 |
2 files changed, 18 insertions, 7 deletions
diff --git a/apioforum/admin.py b/apioforum/admin.py index e591a79..58690b9 100644 --- a/apioforum/admin.py +++ b/apioforum/admin.py @@ -17,5 +17,8 @@ def admin_page(): @admin_required def user_list(): db = get_db() - users = db.execute("select * from users order by joined desc;").fetchall() + users = db.execute("""select *, count(*) as n_posts from users + join posts on posts.author = users.username + group by users.username + order by users.joined desc;""").fetchall() return render_template("admin/users.html",users=users) diff --git a/apioforum/templates/admin/users.html b/apioforum/templates/admin/users.html index 62212e0..ed1eaf9 100644 --- a/apioforum/templates/admin/users.html +++ b/apioforum/templates/admin/users.html @@ -1,14 +1,22 @@ +{% from 'common.html' import ts %} {% extends 'base.html' %} {% block header %} <h1>{% block title %}all apioforum users{% endblock %}</h1> {% endblock %} {% block content %} -<h2>all users</h2> -<ul> - {% for user in users %} - <li>{{disp_user(user.username)}}</li> - {% endfor %} -</ul> +<h2>all users ({{ users | count }})</h2> +<table> +<tr><th>username</th><th>registered</th><th># posts</th></tr> +{% for user in users %} + <tr> + <td>{{disp_user(user.username)}}</td> + <td>{% if user.joined %} + {{user.joined.strftime('%Y-%m-%d')}} {{ts(user.joined)}} + {% else %}antiquity{% endif %}</td> + <td>{{user.n_posts}}</td> + </tr> +{% endfor %} +</table> {% endblock %} |
