mirror of
https://github.com/Doctorado-ML/beflask.git
synced 2025-08-16 15:45:51 +00:00
Users CRUD
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-dark"
|
||||
aria-labelledby="navbarDarkDropdownMenuLink">
|
||||
{% if current_user.admin %}{{ render_nav_item('main.users', 'Users') |safe }}{% endif %}
|
||||
{{ render_nav_item('main.logout', 'Logout') |safe }}
|
||||
</ul>
|
||||
</li>
|
||||
|
@@ -22,13 +22,15 @@
|
||||
<div class="container-fluid">{% include "_nav.html" %}</div>
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
{% for category, message in messages %}
|
||||
{% if category == 'message' %}
|
||||
{% set category = "info" %}
|
||||
{% endif %}
|
||||
<div class="alert alert-{{ category }} alert-dismissible fade show"
|
||||
role="alert">{{ message }}</div>
|
||||
{% endfor %}
|
||||
<div class="col-md-4">
|
||||
{% for category, message in messages %}
|
||||
{% if category == 'message' %}
|
||||
{% set category = "info" %}
|
||||
{% endif %}
|
||||
<div class="alert alert-{{ category }} alert-dismissible fade show"
|
||||
role="alert">{{ message }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
<div class="container-fluid">
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
{% if benchmarks %}
|
||||
{% include "_benchmarks.html" %}
|
||||
<div class="d-flex align-items-center" style="height: 60vh">{% include "_benchmarks.html" %}</div>
|
||||
{% else %}
|
||||
<img src="{{ url_for('static', filename='img/robert-lukeman-_RBcxo9AU-U-unsplash.jpg') }}"
|
||||
class="img-fluid"
|
||||
|
12
app/templates/user.html
Normal file
12
app/templates/user.html
Normal file
@@ -0,0 +1,12 @@
|
||||
{% 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 %}
|
59
app/templates/users.html
Normal file
59
app/templates/users.html
Normal file
@@ -0,0 +1,59 @@
|
||||
{% 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>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
Reference in New Issue
Block a user