155 lines
8.2 KiB
HTML
155 lines
8.2 KiB
HTML
{% extends 'layouts/main-layout.html' %}
|
|
{% block content %}
|
|
{% load static %}
|
|
<div class="page-heading">
|
|
<div class="page-title">
|
|
<div class="row">
|
|
<div class="col-12 col-md-6 order-md-1 order-last">
|
|
<h3>用户</h3>
|
|
</div>
|
|
<div class="col-12 col-md-6 order-md-2 order-first">
|
|
<nav aria-label="breadcrumb" class="breadcrumb-header float-start float-lg-end">
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="/">Dashboard</a></li>
|
|
<li class="breadcrumb-item active" aria-current="page">Users</li>
|
|
</ol>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<section class="section">
|
|
{% if perms.authentication.add_users %}
|
|
<div>
|
|
<button type="button" class="btn btn-sm btn-outline-info my-3"
|
|
hx-get="{% url 'users:add' %}" hx-target="#add-user-modal-content"
|
|
data-bs-toggle="modal" data-bs-target="#add-user-modal">添加用户</button>
|
|
</div>
|
|
{% endif %}
|
|
<!-- Add Modal -->
|
|
<div class="modal fade text-left" id="add-user-modal" tabindex="-1" role="dialog"
|
|
aria-labelledby="myModalLabel160" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
|
<div id="add-user-modal-content" class="modal-content" hx-target="this"></div>
|
|
</div>
|
|
</div>
|
|
<!-- update modal -->
|
|
<div class="modal fade text-left" id="update-user-modal" tabindex="-1" role="dialog"
|
|
aria-labelledby="myModalLabel160" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
|
<div id="update-user-modal-content" class="modal-content" hx-target="this"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
{% if page_object %}
|
|
<div class="d-flex justify-content-end my-2 gap-2">
|
|
<input name="search_text" type="search" class='dataTable-input' autocomplete="off" placeholder='Search here...'
|
|
hx-get="{% url 'users:search' page_object.number %}" hx-trigger="keyup changed delay:500ms, search" hx-target="#search_result">
|
|
{% if request.user.is_superuser %}
|
|
<button
|
|
type="button"
|
|
class="btn btn-secondary rounded"
|
|
data-bs-toggle="dropdown"
|
|
aria-haspopup="true"
|
|
aria-expanded="false"
|
|
><i class="bi bi-download"></i></button>
|
|
<div class="dropdown-menu">
|
|
<a class="dropdown-item" href="{% url 'users:export_users_csv' %}"><i class="bi bi-filetype-csv"></i> CSV Format</a>
|
|
<a class="dropdown-item" href="{% url 'users:export_users_pdf' %}"><i class="bi bi-filetype-pdf"></i> PDF Format</a>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
<table class="table table-hover" id="table1">
|
|
<thead>
|
|
<tr>
|
|
<th>序号</th>
|
|
<th>头像</th>
|
|
<th>姓名</th>
|
|
<th>邮箱</th>
|
|
<th>访问级别</th>
|
|
<th>最后登录</th>
|
|
<th>状态</th>
|
|
{% if request.user.is_superuser %}
|
|
<th>操作</th>
|
|
{% endif %}
|
|
{% if perms.authentication.delete_users or perms.authentication.view_users or perms.authentication.edit_users %}
|
|
<th>操作</th>
|
|
{% endif %}
|
|
</tr>
|
|
</thead>
|
|
{% if page_object %}
|
|
<tbody id="search_result">
|
|
{% for user in page_object %}
|
|
<tr>
|
|
<td>{{page_object.start_index|add:forloop.counter0}}</td>
|
|
<td>
|
|
<div class="user-img d-flex align-items-center">
|
|
<div class="avatar avatar-lg">
|
|
{% if user.profile_pic %}
|
|
<img src="{{user.profile_pic.url}}">
|
|
{% else %}
|
|
<img src="{% static 'assets/images/faces/1.jpg' %}">
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td>{{user.full_name | title}}</td>
|
|
<td>{{user.email}}</td>
|
|
<td>{{user.role}}</td>
|
|
<td>
|
|
{% if user.access_level %}
|
|
All
|
|
{% else %}
|
|
Only Assigned
|
|
{% endif %}
|
|
</td>
|
|
<td>{{user.last_login}}</td>
|
|
{% if request.user.is_superuser %}
|
|
<td>
|
|
<div class="form-check form-switch">
|
|
<input
|
|
class="form-check-input"
|
|
hx-post="{% url 'users:status' user.id %}"
|
|
hx-headers='{"X-CSRFToken":"{{ csrf_token }}"}'
|
|
type="checkbox" {% if user.is_active %} checked {% endif %}
|
|
style="cursor: pointer;"
|
|
>
|
|
</div>
|
|
</td>
|
|
{% endif %}
|
|
<td>
|
|
<div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
|
|
{% if perms.authentication.view_users %}
|
|
<a href="{% url 'users:details' user.id %}" class="btn btn-success"><i class="bi bi-eye-fill"></i></a>
|
|
{% endif %}
|
|
{% if perms.authentication.edit_users %}
|
|
<button type="button" class="btn btn-info"
|
|
hx-get="{% url 'users:update' user.id %}" hx-target="#update-user-modal-content"
|
|
data-bs-toggle="modal" data-bs-target="#update-user-modal"
|
|
><i class="bi bi-pencil-square"></i></button>
|
|
{% endif %}
|
|
{% if perms.authentication.delete_users %}
|
|
<form action="{% url 'users:delete' user.id %}" method="post" onsubmit="return confirm('Are you sure you want to delete this?')">
|
|
{% csrf_token %}
|
|
<button type="submit" value="Delete" class="btn btn-sm btn-danger"><i class="bi bi-trash3-fill"></i></button>
|
|
</form>
|
|
{% endif %}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
{% else %}
|
|
<div class="alert alert-info" role="alert">
|
|
暂无记录
|
|
</div>
|
|
{% endif %}
|
|
</table>
|
|
{% include 'commons/pagination.html' %}
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
{% endblock content %} |