Skip to content
Snippets Groups Projects
Commit 319bd17d authored by Christian Dresen's avatar Christian Dresen
Browse files

[WarpFood] Added function to delete food orders. Closed #27

parent 0750e310
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
{% if sheet.order_time %} {% if sheet.order_time %}
<a href="/pizza/sheet_ordered/{{ sheet.id }}" class="btn btn-success disabled">{% trans "ordered" %}</a> <a href="/pizza/sheet_ordered/{{ sheet.id }}" class="btn btn-success disabled">{% trans "ordered" %}</a>
{% else %} {% else %}
<a href="/pizza/sheet_ordered/{{ sheet.id }}" class="btn btn-danger" id="confirm">{% trans "confirm" %}</a> <a href="/pizza/sheet_ordered/{{ sheet.id }}" class="btn btn-danger" id="confirm_order">{% trans "confirm" %}</a>
{% endif %} {% endif %}
<!-- <a href="/pizza/export_sheet/{{ sheet.id }}" class="btn btn-info">Print order</a> --> <!-- <a href="/pizza/export_sheet/{{ sheet.id }}" class="btn btn-info">Print order</a> -->
{% endif %} {% endif %}
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
<table class="table table-striped table-hover"> <table class="table table-striped table-hover">
<thead> <thead>
<tr> <tr>
<th>&nbsp;&nbsp;<span class="glyphicon glyphicon-trash"></span></th>
<th>{% trans "username" %}</th> <th>{% trans "username" %}</th>
<th>{% trans "article" %}</th> <th>{% trans "article" %}</th>
<th>{% trans "size" %}</th> <th>{% trans "size" %}</th>
...@@ -88,6 +89,7 @@ ...@@ -88,6 +89,7 @@
<tbody> <tbody>
{% for order in orders %} {% for order in orders %}
<tr> <tr>
<td>&nbsp;&nbsp;<a href="#" data-order-id="{{order.id}}" class="confirm_order_delete"><span class="glyphicon glyphicon-minus text-danger"></span></a></td>
<td>{{ order.user }}</td> <td>{{ order.user }}</td>
<td>{{ order.article }}</td> <td>{{ order.article }}</td>
<td>{{ order.size }}</td> <td>{{ order.size }}</td>
...@@ -157,7 +159,7 @@ ...@@ -157,7 +159,7 @@
</div> </div>
<script> <script>
$('#confirm').click(function (e) { $('#confirm_order').click(function (e) {
e.preventDefault(); e.preventDefault();
bootbox.confirm("{% trans "are_you_sure" %}", function (result) { bootbox.confirm("{% trans "are_you_sure" %}", function (result) {
if(result) if(result)
...@@ -166,6 +168,16 @@ ...@@ -166,6 +168,16 @@
} }
}); });
}); });
$('.confirm_order_delete').click(function (e) {
e.preventDefault();
id = $(this).data('order-id')
bootbox.confirm("{% trans "are_you_sure" %}", function (result) {
if(result)
{
window.location = "/pizza/delete_order/"+id;
}
});
});
</script> </script>
{% endblock %} {% endblock %}
......
...@@ -128,3 +128,15 @@ def sheet_ordered(request, sheet_id=0): ...@@ -128,3 +128,15 @@ def sheet_ordered(request, sheet_id=0):
sheet.save() sheet.save()
return redirect("/pizza/view/%s" % sheet_id) return redirect("/pizza/view/%s" % sheet_id)
def delete_order(request, order_id=0):
if order_id != 0:
try:
order = FoodOrder.objects.get(id=order_id)
sheet_id = order.sheet_id
order.delete()
return redirect("/pizza/view/%s" % sheet_id)
except:
pass
return redirect("/")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment