Refactor CID user group form: enhance layout with Bootstrap styling, improve error handling, and update user list presentation

This commit is contained in:
Ross
2025-12-15 12:04:42 +00:00
parent 12bd66d4d8
commit d98305caff
@@ -23,28 +23,46 @@
<form action="" method="post" enctype="multipart/form-data" id="condition-form">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input type="submit" class="submit-button" value="Submit" name="submit">
{% if cidusergroup %}
<p>Users can be added to the group <a href="{% url 'generic:manage_cids' %}">here</a></p>
<h3>Users</h3>
<ul>
{% for user in cidusergroup.ciduser_set.all %}
<li><a href="{% url 'generic:update_cid' user.pk %}">{{user.cid}}</a>: {{user.name}} [{{user.email}} {{user.last_name}}] {{user.userprofile.grade}}</li>
{% empty %}
<li>Group currently has no users.</li>
{% endfor %}
</ul>
Count: {{cidusergroup.ciduser_set.count}}
{% endif %}
<div class="card mb-3">
<div class="card-body">
<div class="row">
<div class="col-12 col-md-8">
{% for field in form.visible_fields %}
<div class="mb-3">
{{ field.label_tag }}
{{ field }}
{% if field.help_text %}
<div class="form-text text-muted">{{ field.help_text }}</div>
{% endif %}
{% if field.errors %}
<div class="text-danger small">{{ field.errors|striptags }}</div>
{% endif %}
</div>
{% endfor %}
<div class="mt-2">
<button type="submit" class="btn btn-primary btn-sm">Save group</button>
<a href="{% url 'generic:manage_cids' %}" class="btn btn-link btn-sm ms-2">Manage CIDs</a>
</div>
</div>
<div class="col-12 col-md-4">
{% if cidusergroup %}
<div class="small text-muted mb-2">Users currently in this group</div>
<ul class="list-group list-group-flush small">
{% for user in cidusergroup.ciduser_set.all %}
<li class="list-group-item bg-transparent border-0 px-0 py-1">
<a href="{% url 'generic:update_cid' user.pk %}">{{ user.cid }}</a>
<div class="text-muted">{{ user.name }} &middot; {{ user.email }}</div>
</li>
{% empty %}
<li class="list-group-item bg-transparent border-0 px-0 py-1 text-muted">Group currently has no users.</li>
{% endfor %}
</ul>
<div class="small text-muted mt-2">Count: {{ cidusergroup.ciduser_set.count }}</div>
{% endif %}
</div>
</div>
</div>
</div>
</form>
{% endblock %}