User Management for Admin
User management for admin
This commit is contained in:
parent
194ef1951b
commit
0b720b9cc0
@ -12,8 +12,15 @@ from ..models import User
|
||||
from ..email import send_email
|
||||
from ..decorators import requires_roles
|
||||
|
||||
@admin.route('/index')
|
||||
@admin.route('/')
|
||||
@login_required
|
||||
@requires_roles("admin")
|
||||
def for_admins_only():
|
||||
return render_template('admin/index.html')
|
||||
def index():
|
||||
return render_template('admin/index.html')
|
||||
|
||||
@admin.route('/list-users')
|
||||
@login_required
|
||||
@requires_roles("admin")
|
||||
def list_users():
|
||||
users = User.query.all()
|
||||
return render_template('admin/list_users.html', users=users)
|
@ -1,8 +1,6 @@
|
||||
<h1>
|
||||
Admin Dashboard
|
||||
<small>Dashboard for Administrators</small>
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="#"><i class="fa fa-dashboard"></i>Home</a></li>
|
||||
<li>Admin Dashboard</li>
|
||||
</ol>
|
||||
<section class="content-header">
|
||||
<h1>
|
||||
Admin Dashboard
|
||||
<small>Dashboard for Administrators</small>
|
||||
</h1>
|
||||
</section>
|
@ -20,4 +20,10 @@
|
||||
|
||||
{% block content_header -%}
|
||||
{% include 'admin/content_header.html' %}
|
||||
{%- endblock content_header %}
|
||||
{%- endblock content_header %}
|
||||
|
||||
{% block content -%}
|
||||
|
||||
<p>Content...</p>
|
||||
|
||||
{%- endblock content %}
|
81
dash/templates/admin/list_users.html
Normal file
81
dash/templates/admin/list_users.html
Normal file
@ -0,0 +1,81 @@
|
||||
{% extends "adminlte/base.html" %}
|
||||
{% import "adminlte/layout.html" as layout with context %}
|
||||
{% import "adminlte/widgets.html" as widgets with context %}
|
||||
|
||||
{% block navbar %}
|
||||
|
||||
{% include "navbar.html" %}
|
||||
|
||||
{%- endblock navbar %}
|
||||
|
||||
|
||||
{% block sidebar -%}
|
||||
|
||||
{% include 'sidebar.html' %}
|
||||
|
||||
{% include 'admin/sidebar_menu.html' %}
|
||||
|
||||
{%- endblock sidebar %}
|
||||
|
||||
|
||||
{% block content_header -%}
|
||||
{% include 'admin/content_header.html' %}
|
||||
{%- endblock content_header %}
|
||||
|
||||
{% block content -%}
|
||||
<!-- Main content -->
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">User List</h3>
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
<div class="box-body">
|
||||
<table id="example2" class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>User ID</th>
|
||||
<th>Username</th>
|
||||
<th>Email</th>
|
||||
<th>Created At</th>
|
||||
<th>Role</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td>{{ user.id }}</td>
|
||||
<td>{{ user.username }}</td>
|
||||
<td>{{ user.email }}</td>
|
||||
<td>{{ user.created_at }}</td>
|
||||
<td>{{ user.role.name }}</td>
|
||||
<td>Edit</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>User ID</th>
|
||||
<th>Username</th>
|
||||
<th>Email</th>
|
||||
<th>Created At</th>
|
||||
<th>Role</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
</div>
|
||||
<!-- /.box -->
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
</section>
|
||||
<!-- /.content -->
|
||||
|
||||
{%- endblock content %}
|
@ -1,7 +1,7 @@
|
||||
<ul class="sidebar-menu">
|
||||
<li class="header">Admin Menu</li>
|
||||
<li>
|
||||
<a href="/admin/index">
|
||||
<a href="{{ url_for('admin.index') }}">
|
||||
<i class="fa fa-dashboard"></i> <span>Admin Dashboard</span>
|
||||
</a>
|
||||
</li>
|
||||
@ -20,7 +20,7 @@
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="">
|
||||
<a href="{{ url_for('admin.list_users') }}">
|
||||
<i class="fa fa-list"></i>
|
||||
List Users
|
||||
</a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user