File size: 3,149 Bytes
f1a0148
 
 
 
 
 
 
 
 
5259aa6
 
 
 
 
 
 
f1a0148
 
 
 
 
 
 
 
 
5259aa6
f1a0148
 
 
 
 
5259aa6
 
 
f1a0148
 
 
 
5259aa6
 
 
 
 
 
 
 
 
 
 
 
f1a0148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{% extends "admin/base.html" %}

{% block admin_content %}
<div class="admin-header">
    <div class="admin-title">Manage Users</div>
</div>

<div class="admin-card">
    <div class="admin-card-header">
        <div class="admin-card-title">All Users (Sorted by Security Score)</div>
        <div class="admin-card-subtitle">
            <span class="badge" style="background-color: #dc3545; color: white;">0-19: High Risk</span>
            <span class="badge" style="background-color: #fd7e14; color: white;">20-39: Medium Risk</span>
            <span class="badge" style="background-color: #ffc107; color: black;">40-69: Low Risk</span>
            <span class="badge" style="background-color: #28a745; color: white;">70-100: Trusted</span>
        </div>
    </div>
    <div class="table-responsive">
        <table class="admin-table">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Username</th>
                    <th>HF ID</th>
                    <th>Join Date</th>
                    <th>Security Score</th>
                    <th>Admin Status</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tbody>
                {% for user_data in users_with_scores %}
                {% set user = user_data.user %}
                {% set score = user_data.security_score %}
                <tr>
                    <td>{{ user.id }}</td>
                    <td>{{ user.username }}</td>
                    <td>{{ user.hf_id }}</td>
                    <td>{{ user.join_date.strftime('%Y-%m-%d %H:%M') if user.join_date else 'N/A' }}</td>
                    <td>
                        {% if score < 20 %}
                        <span class="badge" style="background-color: #dc3545; color: white;" title="High Risk - Votes may be blocked">{{ score }}/100</span>
                        {% elif score < 40 %}
                        <span class="badge" style="background-color: #fd7e14; color: white;" title="Medium Risk - Monitor closely">{{ score }}/100</span>
                        {% elif score < 70 %}
                        <span class="badge" style="background-color: #ffc107; color: black;" title="Low Risk - Normal user">{{ score }}/100</span>
                        {% else %}
                        <span class="badge" style="background-color: #28a745; color: white;" title="Trusted - High security score">{{ score }}/100</span>
                        {% endif %}
                    </td>
                    <td>
                        {% if g.is_admin and user.username in admin_users %}
                        <span class="badge badge-primary">Admin</span>
                        {% else %}
                        <span class="badge badge-secondary">User</span>
                        {% endif %}
                    </td>
                    <td>
                        <a href="{{ url_for('admin.user_detail', user_id=user.id) }}" class="action-btn">View Details</a>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}