Implement user search functionality and enhance supervisor management UI

This commit is contained in:
Ross
2026-06-15 10:28:32 +01:00
parent fc9f2ed6af
commit 35ab7443d2
8 changed files with 268 additions and 44 deletions
+10
View File
@@ -144,6 +144,16 @@ class SupervisorFilter(django_filters.FilterSet):
"site": ["exact"],
}
@property
def qs(self):
parent = super().qs
if "active" not in self.request.GET:
return parent.filter(active=True)
return parent
def __init__(
self,
data=None,
+17 -4
View File
@@ -1,10 +1,23 @@
{% extends 'generic/base.html' %}
{% block navigation %}
{{block.super}}
<br/>
Supervisors: <a href="{% url 'generic:supervisor' %}">View all</a>
<a href="{% url 'generic:supervisor_create' %}">Create new</a>
{{ block.super }}
<div class="container-fluid px-0 mb-3 mt-1">
<div class="d-flex justify-content-between align-items-center bg-dark bg-opacity-50 border border-secondary rounded p-2">
<div class="d-flex align-items-center gap-2">
<span class="text-muted small fw-semibold text-uppercase me-2"><i class="bi bi-person-workspace me-1"></i>Supervisors:</span>
<a href="{% url 'generic:supervisor' %}" class="btn btn-sm btn-outline-info {% if request.resolver_match.url_name == 'supervisor' and 'active' not in request.GET %}active{% endif %}">
<i class="bi bi-person-check-fill me-1"></i>View Active
</a>
<a href="{% url 'generic:supervisor' %}?active=" class="btn btn-sm btn-outline-secondary {% if request.resolver_match.url_name == 'supervisor' and 'active' in request.GET %}active{% endif %}">
<i class="bi bi-people-fill me-1"></i>View All
</a>
<a href="{% url 'generic:supervisor_create' %}" class="btn btn-sm btn-outline-success {% if request.resolver_match.url_name == 'supervisor_create' %}active{% endif %}">
<i class="bi bi-plus-circle-fill me-1"></i>Create New
</a>
</div>
</div>
</div>
{% endblock %}
{% block js %}
+36 -28
View File
@@ -1,34 +1,42 @@
{% extends "generic/supervisor_base.html" %}
<!-- {% load static from static %} -->
{% load crispy_forms_tags %}
{% block css %}
<style>
</style>
{% endblock %}
{% block js %}
<!--<script type="text/javascript" src="/admin/jsi18n/"></script>-->
{{form.media}}
<script type="text/javascript">
</script>
<!-- {{ form.media }} -->
{% endblock %}
{% block content %}
<h2>Edit Supervisor / {{object.cid}}</h2>
<p>Use this form to create / edit a supervisor</p>
<p>Trainees can be assigned to a supervisor by editing the trainee and selecting the supervisor from the drop down list.</p>
{% if errors %}
<div class="alert alert-info" role="alert">{{errors}}</a></div>
{% endif %}
<form action="" method="post" enctype="multipart/form-data" id="condition-form">
{% csrf_token %}
<div class="row justify-content-center mt-3">
<div class="col-12 col-md-8 col-lg-6">
<div class="card border-secondary bg-dark text-white shadow-sm mb-4">
<div class="card-body p-4">
<h2 class="card-title mb-3">
{% if object %}
Edit Supervisor
{% else %}
Create Supervisor
{% endif %}
</h2>
<p class="text-muted small mb-4">
Use this form to manage the supervisor account details. Trainees can be assigned to a supervisor by editing the trainee's profile.
</p>
<table>
{{ form|crispy }}
</table>
<input type="submit" class="submit-button" value="Submit" name="submit">
</form>
{% if errors %}
<div class="alert alert-danger border-danger bg-dark text-danger" role="alert">
{{ errors }}
</div>
{% endif %}
<form action="" method="post" enctype="multipart/form-data" id="supervisor-form">
{% csrf_token %}
{{ form|crispy }}
<div class="mt-4 d-flex gap-2">
<button type="submit" class="btn btn-primary" name="submit">
<i class="bi bi-check-circle me-1"></i>Save changes
</button>
<a href="{% url 'generic:supervisor' %}" class="btn btn-outline-secondary">
Cancel
</a>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
+35 -12
View File
@@ -1,24 +1,47 @@
{% extends 'generic/supervisor_base.html' %}
{% load render_table from django_tables2 %}
{% block content %}
<div class="d-flex flex-wrap justify-content-between align-items-center gap-3 mb-4 mt-2">
<div>
<h2 class="mb-1">Supervisors</h2>
<p class="text-muted mb-0">
Manage registered course and educational supervisors, hospital sites, and trainees.
</p>
</div>
<div class="text-md-end">
<span class="badge bg-secondary rounded-pill px-3 py-2">
Showing: {{ table.rows|length }}
</span>
</div>
</div>
<h2>Supervisors</h2>
<div class="card border-secondary bg-dark text-white shadow-sm mb-4">
<div class="card-body p-0">
<div id="table-div">
<span id="manage-span">
{% render_table table %}
</span>
</div>
</div>
</div>
{% render_table table %}
{% comment %} <ul id="supervisor-list">
{% for supervisor in object_list %}
<li class="supervisor"><a href="{% url 'generic:supervisor_detail' pk=supervisor.pk %}">{{supervisor.name}}</a>
<br/>{{supervisor.email}} [{{supervisor.site}}]
</li>
{% endfor %}
</ul> {% endcomment %}
{% include "generic/partials/filter_bar.html" with filter=filter app_name=app_name collapse_id="bottom-filter-body" %}
{% endblock %}
{% block js %}
<style>
td, th { padding-left: 10px }
.table {
margin-bottom: 0 !important;
}
.table th, .table td {
padding: 0.75rem 1rem !important;
border-color: rgba(255, 255, 255, 0.08) !important;
}
.table thead th {
background-color: rgba(0, 0, 0, 0.2) !important;
color: #d3e9ff !important;
border-bottom: 2px solid rgba(255, 255, 255, 0.15) !important;
}
</style>
{% endblock %}