Implement user search functionality and enhance supervisor management UI
This commit is contained in:
@@ -13,6 +13,31 @@ Trainees can be viewed <a href='{% url "trainees" %}'>here</a> (
|
||||
{% endfor %}
|
||||
)
|
||||
|
||||
<div class="card border-secondary bg-dark text-white mb-4 mt-3">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title mb-3"><i class="bi bi-search me-2"></i>Quick User Search</h4>
|
||||
<div class="row align-items-center g-2">
|
||||
<div class="col-12 col-md-8">
|
||||
<div class="input-group">
|
||||
<span class="input-group-text bg-secondary border-secondary text-white"><i class="bi bi-search"></i></span>
|
||||
<input type="search"
|
||||
name="q"
|
||||
class="form-control bg-dark text-white border-secondary"
|
||||
placeholder="Search users by name, email, or username..."
|
||||
hx-get="{% url 'people' %}"
|
||||
hx-trigger="input delay:300ms, search"
|
||||
hx-target="#search-results"
|
||||
hx-indicator="#search-indicator">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<span id="search-indicator" class="spinner-border spinner-border-sm text-light htmx-indicator" role="status" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="search-results" class="mt-3"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>People</h2>
|
||||
<p>The system contains a number of different people / groups. This affects how they are managed and what they are able to do.</p>
|
||||
<p>They can be managed using the navigation links above</p>
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
{% if users %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-striped align-middle border-secondary text-white">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>Grade</th>
|
||||
<th>Email</th>
|
||||
<th>Supervisor</th>
|
||||
<th>Groups</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td>
|
||||
<div class="fw-bold">
|
||||
{{ user.first_name }} {{ user.last_name }}
|
||||
<a href="{% url 'account_profile' user.username %}" class="text-info ms-1" title="View Profile">
|
||||
<i class="bi bi-person-bounding-box"></i>
|
||||
</a>
|
||||
</div>
|
||||
<small class="text-muted">{{ user.username }}</small>
|
||||
</td>
|
||||
<td>
|
||||
{% if user.userprofile.grade %}
|
||||
<span class="badge bg-secondary">{{ user.userprofile.grade }}</span>
|
||||
{% else %}
|
||||
<span class="text-muted small">No grade</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<small>{{ user.email|default:"—" }}</small>
|
||||
</td>
|
||||
<td>
|
||||
{% if user.userprofile.supervisor %}
|
||||
<div>
|
||||
{{ user.userprofile.supervisor }}
|
||||
<a href="{% url 'generic:supervisor_detail' user.userprofile.supervisor.pk %}" class="text-info ms-1" title="View Supervisor">
|
||||
<i class="bi bi-link-45deg"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% else %}
|
||||
<span class="text-muted small">—</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% for group in user.user_groups.all %}
|
||||
<span class="badge bg-info text-dark me-1">{{ group.name }}</span>
|
||||
{% empty %}
|
||||
<span class="text-muted small">None</span>
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="{% url 'account_update' user.username %}?redirect={{ request.path }}" class="btn btn-outline-light">Edit User</a>
|
||||
<a href="{% url 'account_profile_update' user.username %}?redirect={{ request.path }}" class="btn btn-outline-info">Edit Profile</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="text-muted small mt-2">Showing up to 20 results for "{{ q }}".</div>
|
||||
{% else %}
|
||||
<div class="alert alert-warning border-warning bg-dark text-warning my-2">
|
||||
<i class="bi bi-exclamation-triangle-fill me-2"></i>No users found matching "{{ q }}".
|
||||
</div>
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user