Files

98 lines
4.0 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends "base.html" %}
{% block title %}用户管理 · 后台管理{% endblock %}
{% block content %}
<div class="breadcrumb">
<a href="{% url 'dashboard' %}">后台管理</a><span class="sep">/</span>用户管理
</div>
<div class="page-head">
<h1 class="page-title">用户管理</h1>
<p class="page-subtitle">平台不开放公开注册,账号由管理员在此统一创建和管理。</p>
</div>
<div class="card form-narrow">
<div class="card-header"><svg class="icon"><use href="#i-user"/></svg> 新建用户</div>
<div class="card-body">
<form method="post" action="{% url 'user_list' %}">
{% csrf_token %}
<div class="field">
<label for="{{ form.username.id_for_label }}">{{ form.username.label }}</label>
{{ form.username }}
{{ form.username.errors }}
</div>
<div class="field">
<label for="{{ form.email.id_for_label }}">{{ form.email.label }}</label>
{{ form.email }}
</div>
<div class="grid-2">
<div class="field">
<label for="{{ form.password.id_for_label }}">{{ form.password.label }}</label>
{{ form.password }}
{{ form.password.errors }}
{% if form.password.help_text %}<div class="field-hint">{{ form.password.help_text }}</div>{% endif %}
</div>
<div class="field">
<label for="{{ form.password_confirm.id_for_label }}">{{ form.password_confirm.label }}</label>
{{ form.password_confirm }}
{{ form.password_confirm.errors }}
</div>
</div>
<label class="check-item" style="margin:4px 0 18px">
{{ form.is_staff }} <span>设为管理员(可访问后台管理、查看所有任务)</span>
</label>
<button type="submit" class="btn btn-primary btn-block">创建用户</button>
</form>
</div>
</div>
<div class="card">
<div class="card-header"><svg class="icon"><use href="#i-users"/></svg> 用户列表({{ users|length }})</div>
{% if users %}
<div class="table-wrap">
<table class="table">
<thead>
<tr>
<th>用户名</th>
<th>角色</th>
<th>状态</th>
<th>构建数</th>
<th>注册时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for u in users %}
<tr>
<td>
<strong>{{ u.username }}</strong>
{% if u.email %}<div class="text-muted" style="font-size:12px;margin-top:2px">{{ u.email }}</div>{% endif %}
</td>
<td>
{% if u.is_superuser %}<span class="badge badge-danger">超级管理员</span>
{% elif u.is_staff %}<span class="badge badge-info">管理员</span>
{% else %}<span class="badge badge-secondary">普通用户</span>{% endif %}
</td>
<td>
{% if u.is_active %}<span class="badge badge-success">启用</span>
{% else %}<span class="badge badge-secondary">已停用</span>{% endif %}
</td>
<td>{{ u.build_count }}</td>
<td class="text-muted" style="white-space:nowrap">{{ u.date_joined|date:"Y-m-d" }}</td>
<td>
<a class="btn btn-secondary btn-sm" href="{% url 'user_edit' u.id %}">编辑</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="empty-state">
<div class="empty-icon"><svg class="icon" style="width:42px;height:42px"><use href="#i-user"/></svg></div>
<h3>暂无用户</h3>
</div>
{% endif %}
</div>
{% endblock %}