|
1 | 1 | {% extends "inventory/base.html" %} |
| 2 | + |
2 | 3 | {% block content %} |
3 | | - <div style="display: flex; justify-content: space-between; align-items: center;"> |
| 4 | + <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;"> |
4 | 5 | <h1>Team Management</h1> |
5 | | - <a href="{% url 'inventory:create_user' %}" class="link-button">Add New User</a> |
| 6 | + <a href="{% url 'inventory:create_user' %}" class="btn btn-primary"> |
| 7 | + <i class="fas fa-user-plus"></i> Add New User |
| 8 | + </a> |
6 | 9 | </div> |
7 | | - <p>As an Admin, you can manage the roles of other users in the system.</p> |
| 10 | + <p>As an Admin, you can manage user roles, view their activity status, and control their access to the system.</p> |
8 | 11 |
|
9 | 12 | <table class="open-table"> |
10 | 13 | <thead> |
11 | | - <tr><th>Username</th><th>Email</th><th>Current Role</th><th>Change Role</th></tr> |
| 14 | + <tr> |
| 15 | + <th>Username</th> |
| 16 | + <th>Email</th> |
| 17 | + <th>Role</th> |
| 18 | + <th>Account Status</th> |
| 19 | + <th>Activity Status</th> |
| 20 | + <th style="text-align: center;">Actions</th> |
| 21 | + </tr> |
12 | 22 | </thead> |
13 | 23 | <tbody> |
14 | 24 | {% for profile in users %} |
15 | 25 | <tr> |
| 26 | + <!-- Username --> |
16 | 27 | <td>{{ profile.user.username }}</td> |
17 | | - <td>{{ profile.user.email }}</td> |
18 | | - <td>{{ profile.get_role_display }}</td> |
| 28 | + |
| 29 | + <!-- Email --> |
| 30 | + <td>{{ profile.user.email|default:"Not set" }}</td> |
| 31 | + |
| 32 | + <!-- Role --> |
19 | 33 | <td> |
20 | | - <form action="{% url 'inventory:update_user_role' profile.id %}" method="post"> |
| 34 | + <form action="{% url 'inventory:update_user_role' profile.id %}" method="post" style="margin:0;"> |
21 | 35 | {% csrf_token %} |
22 | | - <select name="role" onchange="this.form.submit()"> |
23 | | - {% for value, name in form.fields.role.choices %} |
| 36 | + <select name="role" onchange="this.form.submit()" class="form-control form-control-sm"> |
| 37 | + {% for value, name in profile.Role.choices %} |
24 | 38 | <option value="{{ value }}" {% if profile.role == value %}selected{% endif %}>{{ name }}</option> |
25 | 39 | {% endfor %} |
26 | 40 | </select> |
27 | 41 | </form> |
28 | 42 | </td> |
| 43 | + |
| 44 | + <!-- Account Status (Active/Suspended) --> |
| 45 | + <td> |
| 46 | + {% if profile.user.is_active %} |
| 47 | + <span class="badge bg-success">Active</span> |
| 48 | + {% else %} |
| 49 | + <span class="badge bg-secondary">Suspended</span> |
| 50 | + {% endif %} |
| 51 | + </td> |
| 52 | + |
| 53 | + <!-- Activity Status (Online/Offline) --> |
| 54 | + <td> |
| 55 | + {% if profile.is_online %} |
| 56 | + <span class="badge bg-primary">Online</span> |
| 57 | + {% else %} |
| 58 | + <span class="badge bg-light text-dark">Offline</span> |
| 59 | + {% endif %} |
| 60 | + </td> |
| 61 | + |
| 62 | + <!-- Actions --> |
| 63 | + <td style="text-align: center; white-space: nowrap;"> |
| 64 | + <!-- Suspend/Reactivate Button --> |
| 65 | + <form action="{% url 'inventory:toggle_user_active' profile.user.id %}" method="post" style="display: inline-block; margin: 0;"> |
| 66 | + {% csrf_token %} |
| 67 | + {% if profile.user.is_active %} |
| 68 | + <button type="submit" class="btn btn-warning btn-sm" title="Suspend this user's account"> |
| 69 | + <i class="fas fa-user-slash"></i> Suspend |
| 70 | + </button> |
| 71 | + {% else %} |
| 72 | + <button type="submit" class="btn btn-success btn-sm" title="Reactivate this user's account"> |
| 73 | + <i class="fas fa-user-check"></i> Reactivate |
| 74 | + </button> |
| 75 | + {% endif %} |
| 76 | + </form> |
| 77 | + |
| 78 | + <!-- Force Logout Button --> |
| 79 | + {% if profile.is_online and profile.user.is_active %} |
| 80 | + <form action="{% url 'inventory:force_logout_user' profile.user.id %}" method="post" style="display: inline-block; margin: 0 0 0 5px;"> |
| 81 | + {% csrf_token %} |
| 82 | + <button type="submit" class="btn btn-danger btn-sm" title="Forcibly end all active sessions for this user" |
| 83 | + onclick="return confirm('Are you sure you want to force logout {{ profile.user.username }}? They will be immediately signed out of all devices.');"> |
| 84 | + <i class="fas fa-sign-out-alt"></i> Force Logout |
| 85 | + </button> |
| 86 | + </form> |
| 87 | + {% endif %} |
| 88 | + </td> |
| 89 | + </tr> |
| 90 | + {% empty %} |
| 91 | + <tr> |
| 92 | + <td colspan="6" style="text-align: center;">There are no other users in the system.</td> |
29 | 93 | </tr> |
30 | 94 | {% endfor %} |
31 | 95 | </tbody> |
|
0 commit comments