Add merge category functionality for admin users with confirmation prompt
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
{% extends 'sbas/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Merge Category</h2>
|
||||
|
||||
{% if error %}
|
||||
<div class="alert alert-danger">{{ error }}</div>
|
||||
{% endif %}
|
||||
|
||||
{% if success %}
|
||||
<div class="alert alert-success">{{ success }}</div>
|
||||
{% endif %}
|
||||
|
||||
<p>This admin tool will move all questions assigned to the <strong>Source</strong> category into the <strong>Target</strong> category. Optionally you may delete the Source category after the move.</p>
|
||||
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<div class="mb-3">
|
||||
<label for="id_source" class="form-label">Source category (to be merged)</label>
|
||||
<select name="source" id="id_source" class="form-select">
|
||||
<option value="">-- select source --</option>
|
||||
{% for c in categories %}
|
||||
<option value="{{ c.pk }}">{{ c }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="id_target" class="form-label">Target category (destination)</label>
|
||||
<select name="target" id="id_target" class="form-select">
|
||||
<option value="">-- select target --</option>
|
||||
{% for c in categories %}
|
||||
<option value="{{ c.pk }}">{{ c }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input class="form-check-input" type="checkbox" value="on" id="id_delete_source" name="delete_source">
|
||||
<label class="form-check-label" for="id_delete_source">
|
||||
Delete source category after merge
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure you want to move all questions from the source to the target category? This action cannot be undone.');">Merge categories</button>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user