def post(self): if not isUserLoggedIn(self): self.redirect("/") return user = getUser(self) aMenuQuantity = int(self.request.get("aMenu")) bMenuQuantity = int(self.request.get("bMenu")) makosQuantity = int(self.request.get("makos")) diosQuantity = int(self.request.get("dios")) addressKey = self.request.get("address") address = Address.get(addressKey) message = self.request.get("message") if aMenuQuantity > 0: aMenuItems = WebshopItem.all().filter("code = ", CHRISTMAS_LUNCH_A) aMenuItem = None if aMenuItems.count() == 1: aMenuItem = aMenuItems.get() christmasOrder = WebshopOrderItem() christmasOrder.address = address christmasOrder.orderDate = datetime.datetime.now() christmasOrder.orderQuantity = aMenuQuantity christmasOrder.item = aMenuItem christmasOrder.user = user if message != None and message != "": christmasOrder.comments = [message] christmasOrder.commentAuthors = ["Én"] christmasOrder.commentDates = [datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")] christmasOrder.put() if bMenuQuantity > 0: bMenuItems = WebshopItem.all().filter("code = ", CHRISTMAS_LUNCH_B) bMenuItem = None if bMenuItems.count() == 1: bMenuItem = bMenuItems.get() christmasOrder = WebshopOrderItem() christmasOrder.address = address christmasOrder.orderDate = datetime.datetime.now() christmasOrder.orderQuantity = bMenuQuantity christmasOrder.item = bMenuItem christmasOrder.user = user if message != None and message != "": christmasOrder.comments = [message] christmasOrder.commentAuthors = ["Én"] christmasOrder.commentDates = [datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")] christmasOrder.put() if makosQuantity > 0: makosItems = WebshopItem.all().filter("code = ", MAKOS_BEIGLI) makosItem = None if makosItems.count() == 1: makosItem = makosItems.get() christmasOrder = WebshopOrderItem() christmasOrder.address = address christmasOrder.orderDate = datetime.datetime.now() christmasOrder.orderQuantity = makosQuantity christmasOrder.item = makosItem christmasOrder.user = user if message != None and message != "": christmasOrder.comments = [message] christmasOrder.commentAuthors = ["Én"] christmasOrder.commentDates = [datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")] christmasOrder.put() if diosQuantity > 0: diosItems = WebshopItem.all().filter("code = ", DIOS_BEIGLI) diosItem = None if diosItems.count() == 1: diosItem = diosItems.get() christmasOrder = WebshopOrderItem() christmasOrder.address = address christmasOrder.orderDate = datetime.datetime.now() christmasOrder.orderQuantity = diosQuantity christmasOrder.item = diosItem christmasOrder.user = user if message != None and message != "": christmasOrder.comments = [message] christmasOrder.commentAuthors = ["Én"] christmasOrder.commentDates = [datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")] christmasOrder.put() self.redirect("/userOrderList")