feat(usermanager): add User list view

This commit is contained in:
Julian Lobbes 2022-11-18 19:04:36 +01:00
parent 95ac626933
commit 4827db3d51
4 changed files with 82 additions and 2 deletions

View File

@ -0,0 +1,38 @@
{% extends 'base.html' %}
{% block content %}
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">Picture</th>
<th scope="col">Username</th>
<th scope="col">Email address</th>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
<th scope="col">Nickname</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<th scope="row">
<img src="{{ url_for('static', filename='images/users/' + user.username + '/thumbnail.jpg') }}"
alt="profile picture for user {{ user.username }}"
class="img-fluid rounded"
style="height: 100px"
>
</th>
<td class="align-middle">
<a href="{{ url_for('usermanager.user_view', username=user.username) }}">{{ user.username }}</a>
</td>
<td class="align-middle">{{ user.email }}</td>
<td class="align-middle">{{ user.first_name }}</td>
<td class="align-middle">{{ user.last_name }}</td>
<td class="align-middle">{{ user.display_name }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock content %}

View File

@ -0,0 +1,16 @@
{% extends 'base.html' %}
{% block content %}
<div>
<div class="container text-center">
<div class="row">
<div class="col-sm-4 border">
Column
</div>
<div class="col-sm-8 border">
Column
</div>
</div>
</div>
</div>
{% endblock content %}

View File

@ -6,6 +6,7 @@
<img src="{{ url_for('static', filename='images/users/' + user.username + '/full.jpg') }}"
alt="profile picture for user {{ user.username }}"
class="img-thumbnail"
style="height: 200px"
>
</div>
</div>

View File

@ -27,7 +27,7 @@ def index():
return render_template('usermanager/index.html')
@bp.route("/user/view/<string:username>")
@bp.route("/users/view/<string:username>")
def user_view(username: str):
"""Detail view for a specific User.
@ -49,6 +49,31 @@ def user_view(username: str):
conn.unbind()
return render_template('usermanager/user_view.html',user=user)
@bp.route("/users/list")
def user_list():
"""Displays a list of all users."""
try:
conn = ldap.get_connection()
users = ldap.get_users(conn)
conn.unbind()
except Exception:
abort(500)
for user in users:
user._generate_static_images()
return render_template(
'usermanager/user_list.html',
users=users,
)
@bp.route("/users/test")
def user_test():
return render_template(
'usermanager/user_test.html',
)
class UserUpdateForm(FlaskForm):
@staticmethod
@ -112,7 +137,7 @@ class UserUpdateForm(FlaskForm):
)
@bp.route("/user/update/<string:username>", methods=("GET", "POST"))
@bp.route("/users/update/<string:username>", methods=("GET", "POST"))
def user_update(username: str):
"""Update view for a specific User.