def insert_user(user_json): #print "INSERT USER" #print user_json user_string = json.loads(user_json) userAddress = Address(number = user_string["number"], street = user_string["street"], postalCode = user_string["postalCode"], city = user_string["city"], province = user_string["province"]) #print "pizzaId: " + user_string["pizzaId"] userOrder = Order(qty = int(user_string["quantity"]), size = int(user_string["pizzaSize"]), pizza_type = int(user_string["pizzaId"])) userAddress.put() userOrder.put() user = User(name = user_string["name"], phoneNumber = user_string["phoneNumber"], email = user_string["email"], addressId = userAddress.key(), orderId = userOrder.key()) user.put() return user.key();
def post(self): if(not isUserLoggedIn(self)): self.redirect("/registration") return user = None userKey=self.session.get(USER_KEY,None) if (userKey != None): user = db.get(userKey) else: self.redirect("/profile") return addressKey = self.request.get("addressKey") address = None if addressKey != None and addressKey != "": address = Address.get(addressKey) if address != None: if (address.user.email != user.email): self.redirect("/profile") return if address == None: address = Address() address.user = user address.billingName = self.request.get("billingName") address.zipNumCode = int(self.request.get("zipNumCode")) address.street = self.request.get("street") address.streetNumber = self.request.get("streetNumber") address.put() self.redirect("/profile")
def get(self): if not isUserAdmin(self): self.session[LOGIN_NEXT_PAGE_KEY] = self.URL self.redirect("/") return addresses = Address.all() address = Address() for address in addresses: address.active = True try: code = int(address.zipCode) if isProperZipCode(code): address.zipNumCode = code else: address.zipNumCode = 1111 except: address.zipNumCode = 1111 address.put() template_values = { 'addresses':addresses } template = jinja_environment.get_template('templates/admin/siteAdmin.html') self.printPage("dashboard", template.render(template_values), False, False)