Merge branch 'master' of github.com:ZeusWPI/Foodbot into feat/19/paid-indicator

* 'master' of github.com:ZeusWPI/Foodbot:
  Check if user is allowed to edit
  spacing
This commit is contained in:
Feliciaan De Palmenaer 2015-06-04 22:08:04 +02:00
commit a5e231cc12
2 changed files with 4 additions and 1 deletions

View file

@ -96,7 +96,7 @@ class Order(db.Model):
group = dict() group = dict()
for item in self.items: for item in self.items:
user = group.get(item.get_name(), dict()) user = group.get(item.get_name(), dict())
user["total"] = user.get("totalm", 0) + item.product.price user["total"] = user.get("total", 0) + item.product.price
user["to_pay"] = user.get("to_pay", 0) + item.product.price if not item.paid else 0 user["to_pay"] = user.get("to_pay", 0) + item.product.price if not item.paid else 0
user["paid"] = user.get("paid", True) and item.paid user["paid"] = user.get("paid", True) and item.paid
user["products"] = user.get("products", []) + [item.product] user["products"] = user.get("products", []) + [item.product]

View file

@ -55,6 +55,8 @@ def order(id, form=None):
@login_required @login_required
def order_edit(id): def order_edit(id):
order = Order.query.filter(Order.id == id).first() order = Order.query.filter(Order.id == id).first()
if current_user.id is not order.courrier_id and not current_user.is_admin():
abort(401)
if order is None: if order is None:
abort(404) abort(404)
orderForm = OrderForm(obj=order) orderForm = OrderForm(obj=order)
@ -65,6 +67,7 @@ def order_edit(id):
return redirect(url_for('.order', id=order.id)) return redirect(url_for('.order', id=order.id))
return render_template('order_edit.html', form=orderForm, order_id=id) return render_template('order_edit.html', form=orderForm, order_id=id)
@order_bp.route('/<id>/create', methods=['POST']) @order_bp.route('/<id>/create', methods=['POST'])
def order_item_create(id): def order_item_create(id):
current_order = Order.query.filter(Order.id == id).first() current_order = Order.query.filter(Order.id == id).first()