feat(usermanager): add group list view
This commit is contained in:
parent
8e9777353e
commit
7572736e0f
@ -13,7 +13,7 @@
|
||||
<table class="table table-hover align-middle" id="groupNonMembers">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" colspan="3" class="text-center">Other users</th>
|
||||
<th scope="col" colspan="3" class="text-center text-opacity-75 fs-4">Other users</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -39,11 +39,11 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-sm border rounded m-2">
|
||||
<div class="col-sm border border-primary rounded m-2">
|
||||
<table class="table table-hover align-middle" id="groupMembers">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" colspan="3" class="text-center">{{ groupname }}</th>
|
||||
<th scope="col" colspan="3" class="text-center text-primary text-opacity-75 fs-4">{{ groupname }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
45
lumi2/templates/usermanager/group_list.html
Normal file
45
lumi2/templates/usermanager/group_list.html
Normal file
@ -0,0 +1,45 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="text-center border-bottom mb-1">
|
||||
<h1>All groups</h1>
|
||||
</div>
|
||||
<div class="text-end border-bottom pb-1 mb-1">
|
||||
<a class="btn btn-primary"
|
||||
href="{{ url_for('usermanager.group_create') }}"
|
||||
role="button"
|
||||
>
|
||||
<img src="{{ url_for('static', filename='/images/base/plus.png') }}" alt="Plus-Icon" width="16" height="16">
|
||||
Create a new group
|
||||
</a>
|
||||
</div>
|
||||
{% if groups %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Group Name</th>
|
||||
<th scope="col">Members</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for group in groups | sort %}
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<a href="{{ url_for('usermanager.group_view', groupname=group.groupname) }}">{{ group.groupname }}</a>
|
||||
</th>
|
||||
<td class="align-middle">
|
||||
{% for user in group.members %}
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="text-center">
|
||||
<p class="text-muted">There are currently no groups.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock content %}
|
@ -58,10 +58,10 @@ def user_view(username: str):
|
||||
conn.unbind()
|
||||
abort(404)
|
||||
|
||||
user._generate_static_images()
|
||||
conn.unbind()
|
||||
return render_template('usermanager/user_view.html',user=user)
|
||||
|
||||
|
||||
@bp.route("/users/list")
|
||||
def user_list():
|
||||
"""Displays a list of all users."""
|
||||
@ -73,9 +73,6 @@ def user_list():
|
||||
except Exception:
|
||||
abort(500)
|
||||
|
||||
for user in users:
|
||||
user._generate_static_images()
|
||||
|
||||
return render_template(
|
||||
'usermanager/user_list.html',
|
||||
users=users,
|
||||
@ -238,8 +235,6 @@ def user_update(username: str):
|
||||
conn.unbind()
|
||||
abort(404)
|
||||
|
||||
user._generate_static_images()
|
||||
|
||||
form = UserUpdateForm(obj=user)
|
||||
if form.validate_on_submit():
|
||||
if form.email.data:
|
||||
@ -252,14 +247,11 @@ def user_update(username: str):
|
||||
user.display_name = form.display_name.data
|
||||
if form.password.data:
|
||||
user.password_hash = User.generate_password_hash(form.password.data)
|
||||
picture_updated = False
|
||||
if form.picture.data and form.picture.data.filename:
|
||||
user.picture = Image.open(form.picture.data, formats=['JPEG'])
|
||||
picture_updated = True
|
||||
|
||||
user._generate_static_images(force=True)
|
||||
ldap.update_user(conn, user)
|
||||
if picture_updated:
|
||||
user._generate_static_images(force=True)
|
||||
conn.unbind()
|
||||
flash(f"Information for user '{user.username}' was updated.")
|
||||
return redirect(url_for('usermanager.user_view', username=user.username))
|
||||
@ -315,6 +307,57 @@ def user_delete(username: str):
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/groups/list")
|
||||
def group_list():
|
||||
"""Displays a list of all groups."""
|
||||
|
||||
try:
|
||||
conn = ldap.get_connection()
|
||||
groups = ldap.get_groups(conn)
|
||||
conn.unbind()
|
||||
except Exception:
|
||||
abort(500)
|
||||
|
||||
return render_template(
|
||||
'usermanager/group_list.html',
|
||||
groups=groups,
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/groups/create", methods=("GET", "POST"))
|
||||
def group_create():
|
||||
"""Displays a form allowing group creation."""
|
||||
|
||||
try:
|
||||
conn = ldap.get_connection()
|
||||
except Exception:
|
||||
abort(500)
|
||||
|
||||
conn.unbind()
|
||||
# TODO implement
|
||||
abort(404)
|
||||
|
||||
|
||||
@bp.route("/groups/view/<string:groupname>")
|
||||
def group_view(groupname: str):
|
||||
"""Displays a form allowing group creation."""
|
||||
|
||||
try:
|
||||
conn = ldap.get_connection()
|
||||
except Exception:
|
||||
abort(500)
|
||||
|
||||
try:
|
||||
group = ldap.get_group(conn, groupname)
|
||||
except ldap.EntryNotFoundException:
|
||||
conn.unbind()
|
||||
abort(404)
|
||||
|
||||
conn.unbind()
|
||||
# TODO implement
|
||||
abort(404)
|
||||
|
||||
|
||||
class GroupUpdateForm(FlaskForm):
|
||||
updated_members = HiddenField(
|
||||
'Group Members',
|
||||
|
Loading…
Reference in New Issue
Block a user