def post(self): username = self.request.get('username') password = self.request.get('password') verify = self.request.get('verify') email = self.request.get('email') if USER_RE.match(username): name_check = True error_User = "" else: name_check = False error_User = "******" if PASSWORD_RE.match(password): password_check = True error_Password = "" if password == verify: verify_check = True error_Verify = "" else: verify_check = False error_Verify = "Your passwords didn't match." else: password_check = False error_Password = "******" error_Verify = "" if email: if EMAIL_RE.match(email): email_check = True error_Email = "" else: email_check = False error_Email = "That's not a valid email." else: email_check = True error_Email = "" if email_check and password_check and verify_check and name_check: Users = db.GqlQuery("SELECT * FROM UserAccount Where User = :1", username).get() if Users: error_User = "******" self.render_front(username, password, verify, email, error_User, error_Password, error_Verify, error_Email) else: h = make_pw_hash(username, password) p = UserAccount(User = username, Password = h, Email = email) p.put() x = str(p.key().id()) hashed_user = make_secure_val(x) self.response.headers.add_header('Set-Cookie', 'user_id=%s' %str(hashed_user)) self.redirect("/welcome") else: self.render_front(username, password, verify, email, error_User, error_Password, error_Verify, error_Email, "","")
def get(self): User_id = self.request.cookies.get('user_id') Valid_User = check_secure_val(User_id) if Valid_User: p = UserAccount.get_by_id(int(Valid_User)) self.render("welcome.html", User = p.User) else: self.redirect("/signup")
def get(self): User_id = self.request.cookies.get('user_id') if User_id: Valid_User = check_secure_val(User_id) if Valid_User: p = UserAccount.get_by_id(int(Valid_User)) self.render_front(p.User) else: self.render_front() else: self.render_front()
def render_front(self, User="", error=""): User_id = self.request.cookies.get("user_id") if User_id: Valid_User = check_secure_val(User_id) if Valid_User: p = UserAccount.get_by_id(int(Valid_User)) User = p.User else: User = "" else: User = "" self.render("firmware.html", User=User, error="")
def render_front(self, User = ""): User_id = self.request.cookies.get('user_id') if User_id: Valid_User = check_secure_val(User_id) if Valid_User: p = UserAccount.get_by_id(int(Valid_User)) User = p.User else: User = "" else: User = "" self.render("purchase.html", User = User)
def render_front(self, User = "", username = "", password ="", error = ""): User_id = self.request.cookies.get('user_id') if User_id: Valid_User = check_secure_val(User_id) if Valid_User: p = UserAccount.get_by_id(int(Valid_User)) User = p.User else: User = "" else: User = "" self.render("login.html", User = "", username = username, password = password, error = error)
def render_front(self, error = "", Blog_error=""): User_id = self.request.cookies.get('user_id') if User_id: Valid_User = check_secure_val(User_id) if Valid_User: p = UserAccount.get_by_id(int(Valid_User)) User = p.User else: User = "" else: User = "" posts = db.GqlQuery("SELECT * FROM Blogpost " "ORDER BY created DESC") self.render("contact.html", User = User, error = "", Blog_error = Blog_error, posts = posts )
def post(self): User_id = self.request.cookies.get('user_id') Valid_User = check_secure_val(User_id) p = UserAccount.get_by_id(int(Valid_User)) User = p.User newpost_bpost = self.request.get("content") posts = db.GqlQuery("SELECT * FROM Blogpost " "ORDER BY created DESC") if newpost_bpost: posts = Blogpost(bpost = newpost_bpost, user = User) posts.put() posts = db.GqlQuery("SELECT * FROM Blogpost " "ORDER BY created DESC") self.render("contact.html", User = User, error="", posts = posts) else: error = "not a valid post" self.render("contact.html", User = User, error = "", posts = posts, Blog_error = "Please enter some text before submitting.")
def post(self): User_id = self.request.cookies.get('user_id') Valid_User = check_secure_val(User_id) p = UserAccount.get_by_id(int(Valid_User)) User = p.User Address = self.request.get("Address") City = self.request.get("City") State = self.request.get("State") Country = self.request.get("Country") Quantity = self.request.get("Quantity") if User and Address and City and State and Country and Quantity: posts = Purchase_Order(User = User, Address = Address, City = City, State = State, Country=Country, Quantity=Quantity) posts.put() self.render("Thankyou.html", User = User) else: error = 'Please complete all the fields.' self.render("purchase.html", User=User, error = error)