Add bulk add functionality for user and CID groups to exam collections

This commit is contained in:
Ross
2025-11-12 21:19:09 +00:00
parent c39d30c746
commit ec0245fe7c
7 changed files with 207 additions and 3 deletions
@@ -86,9 +86,13 @@
{% endif %}
<br/>
<div id="add-user">
<button hx-get="{% url 'generic:exam_collection_add_author' object.pk %}" hx-target="#add-user" hx-swap="innerHTML">Add author to all exams</button>
</div>
<div id="bulk-add-groups">
<button class="btn-sm" hx-get="{% url 'generic:exam_collection_bulk_add_groups' object.pk %}" hx-target="#bulk-add-groups" hx-swap="innerHTML">Add groups to exams</button>
</div>
<div id="add-user">
<button hx-get="{% url 'generic:exam_collection_add_author' object.pk %}" hx-target="#add-user" hx-swap="innerHTML">Add author to all exams</button>
</div>
{% include 'exam_overview_js.html' %}
@@ -0,0 +1,19 @@
<form hx-post="{% url 'generic:exam_collection_bulk_add_groups' collection.pk %}" hx-target="#bulk-add-groups" hx-swap="innerHTML" class="bulk-add-groups-form">
{% csrf_token %}
<div>
{{ form.cid_user_groups.label_tag }}<br/>
{{ form.cid_user_groups }}
</div>
<div>
{{ form.user_user_groups.label_tag }}<br/>
{{ form.user_user_groups }}
</div>
<div>
{{ form.exam_types.label_tag }}<br/>
{{ form.exam_types }}
</div>
<div class="mt-2">
<button type="submit" class="btn btn-primary btn-sm">Add groups</button>
<button type="button" class="btn btn-secondary btn-sm" hx-get="{% url 'generic:examcollection_detail' collection.pk %}" hx-target="#bulk-add-groups" hx-swap="innerHTML">Cancel</button>
</div>
</form>
@@ -0,0 +1,11 @@
<div class="bulk-add-result">
{% if error %}
<div class="alert alert-danger">Error: {{ error }}</div>
{% else %}
<p>Added user groups to {{ total_user }} exams.</p>
<p>Added CID groups to {{ total_cid }} exams.</p>
{% endif %}
<div class="mt-2">
<button class="btn btn-sm btn-outline-primary" hx-get="{% url 'generic:exam_collection_bulk_add_groups' collection.pk %}" hx-target="#bulk-add-groups" hx-swap="innerHTML">Add more</button>
</div>
</div>