admin blueprint

This commit is contained in:
2023-06-08 19:58:07 +02:00
parent f7064811d7
commit bc57f6f747
12 changed files with 288 additions and 253 deletions

View File

@@ -15,7 +15,7 @@
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
{% if current_user.is_authenticated %}
<li class="nav-benchmark">
<a href="{{ url_for("main.index") }}"
<a href="{{ url_for(config.INDEX) }}"
class="nav-item nav-link nav-benchmark">on {{ current_user.benchmark.name }}</a>
</li>
{% endif %}
@@ -37,9 +37,9 @@
</a>
<ul class="dropdown-menu dropdown-menu-dark"
aria-labelledby="navbarDarkDropdownMenuLink">
{% if current_user.admin %}{{ render_nav_item('main.users', 'Users') |safe }}{% endif %}
{% if current_user.admin %}{{ render_nav_item('admin.users', 'Users') |safe }}{% endif %}
<a class="nav-item nav-link"
href="{{ url_for("main.password", user_id=current_user.id) }}">Password</a>
href="{{ url_for("admin.password", user_id=current_user.id) }}">Password</a>
{{ render_nav_item('main.logout', 'Logout') |safe }}
</ul>
</li>

View File

@@ -1,12 +0,0 @@
{% extends "base.html" %}
{% from 'bootstrap5/form.html' import render_form %}
{% block content %}
<div class="alert alert-info col-md-4" role="alert">
<h4 class="alert-heading">Change password for {{ user_name }}</h4>
<button class="btn btn-primary"
onclick="window.location.href='{{ url_for(back) }}'">Back</button>
<div class="row">
<div>{{ render_form(form) }}</div>
</div>
</div>
{% endblock %}

View File

@@ -1,12 +0,0 @@
{% extends "base.html" %}
{% from 'bootstrap5/form.html' import render_form %}
{% block content %}
<div class="alert alert-{{ alert_type }} col-md-4" role="alert">
<h4 class="alert-heading">{{ title }}</h4>
<button class="btn btn-primary"
onclick="window.location.href='{{ url_for("main.users") }}'">Back</button>
<div class="row">
<div>{{ render_form(form) }}</div>
</div>
</div>
{% endblock %}

View File

@@ -1,61 +0,0 @@
{% extends "report_tables.html" %}
{% block content %}
<div class="container col-7">
<div class="alert alert-primary" role="alert">
<div class="navbar">
<div class="float-left">
<h2>
User <b>Management</b>
</h2>
</div>
<div class="float-end">
<a href="{{ url_for("main.user_new") }}" class="btn btn-primary"><span><i class="mdi mdi-plus-circle"></i> Add New User</span></a>
</div>
</div>
<hr>
</div>
<div class="float-left">
<table id="report-table"
class="table table-striped table-hover table-bordered bg-light"
data-toggle="table"
data-sticky-header="true"
data-sticky-header-offset-y="65"
data-sortable="true">
<thead>
<tr class="bg-primary text-white">
<th class="text-center">Username</th>
<th class="text-center">Email</th>
<th class="text-center">Date Created</th>
<th class="text-center">Last Login</th>
<th class="text-center">Is Admin</th>
<th class="text-center">Benchmark</th>
<th class="text-center">Actions</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.username }}</td>
<td>{{ user.email }}</td>
<td class="text-center">{{ user.date_created.strftime("%d-%m-%Y, %T") }}</td>
<td class="text-center">{{ user.last_login.strftime("%d-%m-%Y, %T") }}</td>
<td class="text-center">
<input type="checkbox" onclick="return false" {{ "checked" if user.admin else "" }}>
</td>
<td>{{ user.benchmark.name }}</td>
<td>
<a href="{{ url_for("main.user_edit", user_id=user.id) }}"
class="btn btn-primary"><span><i class="mdi mdi-account"></i></span></a>
<a href="{{ url_for("main.user_delete", user_id=user.id) }}"
class="btn btn-danger"><i class="mdi mdi-account-remove"></i></a>
<a href="{{ url_for("main.password", user_id=user.id, back="main.users") }}"
class="btn btn-warning"><i class="mdi mdi-lock-reset"></i></a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endblock content %}