diff --git a/www/web/warpfood/templates/warpfood/view.html b/www/web/warpfood/templates/warpfood/view.html index 9a6b6a46753c641b8023a63e7e57bc86471bf231..3f9c929af730c2a46032f94ae9bf18de7515a648 100644 --- a/www/web/warpfood/templates/warpfood/view.html +++ b/www/web/warpfood/templates/warpfood/view.html @@ -31,7 +31,7 @@ {% if sheet.order_time %} <a href="/pizza/sheet_ordered/{{ sheet.id }}" class="btn btn-success disabled">{% trans "ordered" %}</a> {% 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 %} <!-- <a href="/pizza/export_sheet/{{ sheet.id }}" class="btn btn-info">Print order</a> --> {% endif %} @@ -77,6 +77,7 @@ <table class="table table-striped table-hover"> <thead> <tr> + <th> <span class="glyphicon glyphicon-trash"></span></th> <th>{% trans "username" %}</th> <th>{% trans "article" %}</th> <th>{% trans "size" %}</th> @@ -88,6 +89,7 @@ <tbody> {% for order in orders %} <tr> + <td> <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.article }}</td> <td>{{ order.size }}</td> @@ -157,7 +159,7 @@ </div> <script> - $('#confirm').click(function (e) { + $('#confirm_order').click(function (e) { e.preventDefault(); bootbox.confirm("{% trans "are_you_sure" %}", function (result) { if(result) @@ -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> {% endblock %} diff --git a/www/web/warpfood/views.py b/www/web/warpfood/views.py index 15d3a02cd2cf02e970c1e5c6d5822dc458b3c1e2..034dc9cbb75ff166008ed4433445547780ce88b2 100644 --- a/www/web/warpfood/views.py +++ b/www/web/warpfood/views.py @@ -128,3 +128,15 @@ def sheet_ordered(request, sheet_id=0): sheet.save() 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("/")