File size: 3,564 Bytes
f256f5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{% extends "admin_layout.html" %}
{% block admin_title %}注册码{% endblock %}
{% block admin_page_content %}
<section class="content-grid admin-grid reveal-up delay-2">
    <article class="card">
        <div class="card-head">
            <span class="kicker">注册码</span>
            <h2>创建注册码</h2>
            <p>学生拿到注册码后即可在 <code>/register</code> 页面使用学号和教务处密码完成注册。</p>
        </div>
        <form method="post" action="{{ url_for('create_registration_code') }}" class="form-grid form-grid-compact">
            <label class="field span-2">
                <span>备注</span>
                <input type="text" name="note" placeholder="例如 2025 春季新用户批次">
            </label>
            <label class="field">
                <span>可用次数</span>
                <input type="number" name="max_uses" min="1" max="99" value="{{ default_registration_code_max_uses }}" required>
            </label>
            <button type="submit" class="btn btn-secondary">生成注册码</button>
        </form>
    </article>

    <article class="card">
        <div class="card-head">
            <span class="kicker">使用说明</span>
            <h2>给学生的注册提示</h2>
            <p>建议提示用户使用学号和教务处密码注册;注册码只负责开通本系统账号,不替代教务处认证。</p>
        </div>
        <div class="button-row wrap-row">
            <a href="{{ url_for('admin_users') }}" class="btn btn-ghost">返回用户管理</a>
        </div>
    </article>
</section>

<section class="card reveal-up delay-3 span-2">
    <div class="card-head split">
        <div>
            <span class="kicker">注册码清单</span>
            <h2>注册码状态</h2>
            <p>可以查看注册码是否启用、可用次数、已用次数以及最近一次使用情况。</p>
        </div>
    </div>
    <div class="course-table-wrap">
        <table class="data-table">
            <thead>
                <tr>
                    <th>注册码</th>
                    <th>备注</th>
                    <th>状态</th>
                    <th>使用</th>
                    <th>最近使用者</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {% if registration_codes %}
                    {% for code in registration_codes %}
                        <tr>
                            <td><code>{{ code.code }}</code></td>
                            <td>{{ code.note or '无' }}</td>
                            <td>{{ '启用' if code.is_active else '停用' }}</td>
                            <td>{{ code.used_count }}/{{ code.max_uses }}</td>
                            <td>{{ code.used_by_student_id or '暂无' }}</td>
                            <td>
                                <form method="post" action="{{ url_for('toggle_registration_code', registration_code_id=code.id) }}">
                                    <button type="submit" class="inline-action">{{ '停用' if code.is_active else '启用' }}</button>
                                </form>
                            </td>
                        </tr>
                    {% endfor %}
                {% else %}
                    <tr>
                        <td colspan="6" class="empty-cell">还没有创建注册码。</td>
                    </tr>
                {% endif %}
            </tbody>
        </table>
    </div>
</section>
{% endblock %}