mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-06-21 03:58:23 +02:00
Add a delete question button
This commit is contained in:
@ -181,13 +181,23 @@
|
||||
{% url "participation:add_question" pk=participation.pk as modal_action %}
|
||||
{% include "base_modal.html" with modal_id="addQuestion" modal_button_type="success" %}
|
||||
{% for question in participation.questions.all %}
|
||||
{% trans "Update question" as modal_title %}
|
||||
{% trans "Update" as modal_button %}
|
||||
{% url "participation:update_question" pk=question.pk as modal_action %}
|
||||
{% with number_str=forloop.counter|stringformat:"d" %}
|
||||
{% with modal_id="updateQuestion"|add:number_str %}
|
||||
{% include "base_modal.html" %}
|
||||
{% endwith %}
|
||||
{% with number_str=forloop.counter|stringformat:"d"%}
|
||||
{% with modal_id="updateQuestion"|add:number_str %}
|
||||
{% trans "Delete" as delete %}
|
||||
{% with extra_modal_button='<button class="btn btn-danger" type="button" data-dismiss="modal" data-toggle="modal" data-target="#deleteQuestion'|add:number_str|add:'Modal">'|add:delete|add:"</button>"|safe %}
|
||||
{% trans "Update question" as modal_title %}
|
||||
{% trans "Update" as modal_button %}
|
||||
{% url "participation:update_question" pk=question.pk as modal_action %}
|
||||
{% include "base_modal.html" %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
|
||||
{% with modal_id="deleteQuestion"|add:number_str %}
|
||||
{% trans "Delete question" as modal_title %}
|
||||
{% trans "Delete" as modal_button %}
|
||||
{% url "participation:delete_question" pk=question.pk as modal_action %}
|
||||
{% include "base_modal.html" with modal_button_type="danger" %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
@ -223,6 +233,12 @@
|
||||
if (!modalBody.html().trim())
|
||||
modalBody.load("{% url "participation:update_question" pk=question.pk %} #form-content");
|
||||
});
|
||||
|
||||
$('button[data-target="#deleteQuestion{{ forloop.counter }}Modal"]').click(function() {
|
||||
let modalBody = $("#deleteQuestion{{ forloop.counter }}Modal div.modal-body");
|
||||
if (!modalBody.html().trim())
|
||||
modalBody.load("{% url "participation:delete_question" pk=question.pk %} #form-content");
|
||||
});
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% load crispy_forms_filters i18n %}
|
||||
|
||||
{% block content %}
|
||||
<form method="post">
|
||||
<div id="form-content">
|
||||
<div class="alert alert-danger">
|
||||
{% trans "Are you sure you want to delete this question?" %}
|
||||
</div>
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
</div>
|
||||
<button class="btn btn-danger" type="submit">{% trans "Delete" %}</button>
|
||||
</form>
|
||||
{% endblock content %}
|
||||
|
Reference in New Issue
Block a user