mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-08 22:17:34 +01:00
Redesign user list
This commit is contained in:
parent
cd520a0251
commit
ab58570a0c
@ -81,7 +81,7 @@ def list_all():
|
||||
topics = qb.buildTopicQuery().all()
|
||||
|
||||
tags = db.session.query(func.count(Tags.c.tag_id), Tag) \
|
||||
.select_from(Tag).outerjoin(Tags).group_by(Tag.id).order_by(db.asc(Tag.title))
|
||||
.select_from(Tag).outerjoin(Tags).group_by(Tag.id).order_by(db.asc(Tag.title)).all()
|
||||
|
||||
selected_tags = set(qb.tags)
|
||||
|
||||
|
@ -28,6 +28,7 @@ from app.utils import randomString, loginUser, rank_required, nonEmptyOrNone, ad
|
||||
from app.tasks.forumtasks import checkForumAccount
|
||||
from app.tasks.emails import sendVerifyEmail, sendEmailRaw
|
||||
from app.tasks.phpbbparser import getProfile
|
||||
from sqlalchemy import func
|
||||
|
||||
# Define the User profile form
|
||||
class UserProfileForm(FlaskForm):
|
||||
@ -43,7 +44,11 @@ class UserProfileForm(FlaskForm):
|
||||
|
||||
@bp.route("/users/", methods=["GET"])
|
||||
def list_all():
|
||||
users = User.query.order_by(db.desc(User.rank), db.asc(User.display_name)).all()
|
||||
users = db.session.query(User, func.count(Package.id)) \
|
||||
.select_from(User).outerjoin(Package) \
|
||||
.order_by(db.desc(User.rank), db.asc(User.display_name)) \
|
||||
.group_by(User.id).all()
|
||||
|
||||
return render_template("users/list.html", users=users)
|
||||
|
||||
|
||||
|
@ -1,20 +1,59 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}
|
||||
Users
|
||||
{{ _("Users") }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<ul class="userlist">
|
||||
{% for user in users %}
|
||||
<li>
|
||||
<a href="{{ url_for('users.profile', username=user.username) }}" class="{{ user.rank }}">
|
||||
{{ user.display_name }}
|
||||
</a> -
|
||||
{{ user.rank.getTitle() }}
|
||||
{% if current_user.is_authenticated %}
|
||||
- {{ user.packages.count() }} packages.
|
||||
{% endif %}
|
||||
<h1>{{ _("Users") }}</h1>
|
||||
|
||||
<div class="userlist list-group">
|
||||
<div class="list-group-item">
|
||||
<div class="row text-muted">
|
||||
<div class="col-sm-2">
|
||||
{{ _("Rank") }}
|
||||
</div>
|
||||
|
||||
<span class="col-sm">
|
||||
{{ _("Username") }}
|
||||
</span>
|
||||
|
||||
<div class="col-sm-1 text-center">
|
||||
{{ _("Packages") }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% for pair in users %}
|
||||
{% set user = pair[0] %}
|
||||
{% set count_pkgs = pair[1] %}
|
||||
|
||||
<a class="list-group-item list-group-item-action" href="{{ url_for('users.profile', username=user.username) }}">
|
||||
<div class="row">
|
||||
<div class="col-sm-2 {{ user.rank }}"
|
||||
title="{{ _('Rank: %(rank)s.', rank=user.rank.getTitle()) }}">
|
||||
{% if user.rank == user.rank.ADMIN %}
|
||||
<i class="fas fa-user-cog mr-2"></i>
|
||||
{% elif user.rank == user.rank.MODERATOR %}
|
||||
<i class="fas fa-user-shield mr-2"></i>
|
||||
{% elif user.rank == user.rank.EDITOR %}
|
||||
<i class="fas fa-user-edit mr-2"></i>
|
||||
{% else %}
|
||||
<i class="fas fa-user mr-2"></i>
|
||||
{% endif %}
|
||||
|
||||
{{ user.rank.getTitle() }}
|
||||
</div>
|
||||
|
||||
<span class="col-sm {{ user.rank }}">
|
||||
{{ user.display_name }}
|
||||
</span>
|
||||
|
||||
<div class="col-sm-1 text-center">
|
||||
<b>{{ count_pkgs }}</b>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user