Url and template for InventoryDeleteView

This commit is contained in:
Ludovic Stephan 2020-09-11 15:22:02 +02:00 committed by Martin Pépin
parent 59dacda37d
commit f3701d91fc
No known key found for this signature in database
GPG key ID: E7520278B1774448
2 changed files with 39 additions and 0 deletions

View file

@ -19,6 +19,17 @@
</li> </li>
{% endif %} {% endif %}
</ul> </ul>
{% if perms.kfet.delete_inventory %}
<hr>
<div class="buttons">
<button class="btn btn-default" id="button-delete">
<span class="glyphicon glyphicon-remove"></span><span>Annuler l'inventaire</span>
</button>
<form method="post" action="{% url 'kfet.inventory.delete' inventory.pk %}" id="inventory-delete-form">
{% csrf_token %}
</form>
{% endif %}
</div>
</div> </div>
</aside> </aside>
@ -64,4 +75,27 @@
</table> </table>
</div> </div>
<script type="text/javascript">
$( function() {
// Delete button
$('#button-delete').click(function() {
$.confirm({
title: 'Confirmer la suppression',
content: `
<div class="warning">
<span class='glyphicon glyphicon-warning-sign'></span><span>Cette opération est irréversible !</span>
</div>
`,
backgroundDismiss: true,
animation: 'top',
closeAnimation: 'bottom',
keyboardEnabled: true,
confirm: function() {
$('#inventory-delete-form').submit();
}
})
})
});
</script>
{% endblock %} {% endblock %}

View file

@ -270,6 +270,11 @@ urlpatterns = [
teamkfet_required(views.InventoryRead.as_view()), teamkfet_required(views.InventoryRead.as_view()),
name="kfet.inventory.read", name="kfet.inventory.read",
), ),
path(
"inventaires/<int:pk>/delete",
views.InventoryDelete.as_view(),
name="kfet.inventory.delete",
),
# ----- # -----
# Order urls # Order urls
# ----- # -----