Esempio n. 1
0
def signup(response):
    username = response.get_field("username")
    firstname = response.get_field("firstname")
    lastname = response.get_field("lastname")
    email = response.get_field("email")
    password = response.get_field("password")
    school = response.get_field("school")
    print username
    if username and email and firstname and lastname and password and not User.exists(
            username):
        newUser = {
            "username": username,
            "firstname": firstname,
            "lastname": lastname,
            "email": email,
            "password": password,
            "school": school
        }
        User.add(newUser)
        print " I am here"
        x = User.get(username)
        print x
        # we're going to be hacky, and manually set a cookie, which shouldn't happen -
        # but we want to prevent the user from being redirected to the login page, straight
        # after signing up.
        response.set_cookie("User", username)
        response.redirect("/profile/" + username)
    else:
        #response.write(SIGNUP)
        title = "Sign Up"
        context = {"title": title, "css": "signup", "user": None}
        template.render_template("templates/signup.html", context, response)
Esempio n. 2
0
def signup(response):
    username = response.get_field("username")
    firstname = response.get_field("firstname")
    lastname = response.get_field("lastname")
    email = response.get_field("email")
    password = response.get_field("password")
    school = response.get_field("school")
    print username
    if username and email and firstname and lastname and password and not User.exists(username):
        newUser = {"username": username, "firstname":firstname,"lastname":lastname,"email":email,"password":password,"school":school}
        User.add(newUser)
        print " I am here"
        x = User.get(username)
        print x
        # we're going to be hacky, and manually set a cookie, which shouldn't happen -
        # but we want to prevent the user from being redirected to the login page, straight
        # after signing up.
        response.set_cookie("User", username)
        response.redirect("/profile/" + username)
    else:
        #response.write(SIGNUP)
        title = "Sign Up"
        context = {"title":title, "css":"signup", "user":None}
        template.render_template("templates/signup.html", context, response)