Beispiel #1
0
 def post(self):
     user = users.get_current_user()
     dish_name = self.request.get('dish_name')
     restaurant_name = self.request.get('restaurant_name')
     id = int(self.request.get('id'))
     cart = CartModel.query(CartModel.user==user, CartModel.restaurant_name==restaurant_name).fetch()[0]
     order = OrderModel.get_by_id(id)
     order.number = order.number + 1
     order.put()
     dish = order.dish.get()
     cart.total = cart.total + dish.price
     cart.put()
     # url = "/test?name=%s" % dish_name
     info = {"name": dish_name, "other": restaurant_name, "id":id, 'total': cart.total}
     info_json = json.dumps(info)
     self.response.write(info_json)
Beispiel #2
0
 def get(self):
     user = users.get_current_user()
     restaurant_name = self.request.get('restaurant_name')
     id = int(self.request.get('id'))
     order = OrderModel.get_by_id(id)
     cart_query = CartModel.query(CartModel.restaurant_name==restaurant_name, CartModel.user==user).fetch()
     if (len(cart_query)>0):
         dish = order.dish.get()
         cart = cart_query[0]
         cart.orders.remove(order.key)
         cart.total = cart.total - order.number*dish.price
         cart.put()
         order.key.delete()
         p = urllib.urlencode({'name':restaurant_name})
         URL = '/viewsinglecart?%s' % p
         self.redirect(URL)
     else:
         self.redirect('/error')