Example #1
0
def signup():
    # check if form was submitted
    form = request.form.keys()
    if 'username' in form and 'password' in form and 'password_repeat' in form:

        # read the data from the form
        username = request.form['username']
        password = request.form['password']
        password_repeat = request.form['password_repeat']

        # make sure that the form data is valid
        valid = True

        if not password == password_repeat:  # if they typed in a different password in repeat
            flash('Passwords do not match!', 'danger')
            valid = False

        if not User.username_avaliable(
                username):  # checks database if username already exists
            flash('Username already taken!', 'danger')
            valid = False

        if valid:
            User.new_user(username, password)
            flash("Account successfully created!", "success")
            return redirect('login')
    return render_template('signup.html', title='Sign Up')
Example #2
0
def populate():
    for x in range(50):
        gen = r.choice(["Male", "Female"])
        format = lambda input : input if len(f"{input}") > 1 else f"0{input}"
        date = f"{r.randint(2000, 2019)}-{format(r.randint(1, 12))}-{format(r.randint(10, 28))}"
        #username = ""
        #for i in range(10):
        #    username += r.choice(string.ascii_lowercase)
        User.new_user(x, "", names.get_full_name(gender=gen.lower()), gen, r.choice(["Both", "Males", "Females"]), date, "dummy email", "dummy phone number", "lorem ipsum shut up", f"{r.uniform(35, 45)},{r.uniform(-80, 70)}")
Example #3
0
def createAccount():
    '''When you create an account, you have to submit a bunch of personal information'''
    if (request.form["password"] != request.form["password-confirm"]):
        return redirect("/create")
    for data in request.form:
        if (len(request.form[data]) == 0):
            print("bad")
            flash("Please enter a value in every field")
            return redirect("/create")
    loc_info = api.json2dict(api.ip_location(
        api.user_ip()))  #current ip location
    if not User.new_user(request.form["username"], request.form["password"],
                         request.form["name"], request.form["gender"],
                         request.form["preference"], request.form["dob"],
                         request.form["email"], request.form["phone"],
                         request.form["bio"],
                         f"{loc_info['lat']},{loc_info['lon']}"):
        return redirect("/create")
    session["username"] = request.form["username"]
    if ("prev_url" in session):
        return redirect(session.pop("prev_url"))
    return redirect("/welcome")