Ejemplo n.º 1
0
def test_validate(test_input, expected):
    result = validate(test_input)
    assert result[0] == expected[0]
    assert result[2] == expected[2]
    # workaround due to python's inability to compare numpy ndarrays
    comparison = result[1] == expected[1]
    if expected[1] is not None:
        assert comparison.all()
    else:
        assert comparison
Ejemplo n.º 2
0
def default():
    if request.method == 'GET':
        return render_template('homepage.html')
    else:
        user = request.form['username']
        password = request.form['password']
        results = storage.validate(self, user, password)
        if results:
            return redirect(url_for('index'))
        else:
            return render_template('homepage.html', results = results)
Ejemplo n.º 3
0
def login():
    if request.method == 'GET':
        return render_template('homepage.html', success = success)
    else:
        global uname
        global password
        uname = request.form['username']
        password = request.form['password']
        res = 0
        if uname and password:
            res = storage.validate(uname, password)
        if res == 1:
            return redirect(url_for("search", uname=uname))
        else:
            return render_template('homepage.html', res = "retry or register")
Ejemplo n.º 4
0
def register():
    if request.method == 'GET':
        return render_template('register.html')
    else:
        btn = request.form['Go']
        if btn == "Submit":
            global success
            global user_hashtag
            global uname
            uerror = ""
            uname = ""
            password = ""
            fullname = ""
            
            user_hashtag = ""
            uname = request.form['username']
            password = request.form['pswd']
            fullname = request.form['name']
            user_hashtag = request.form['hashtag']
            tunames = []
            x = request.form['tuname']
           
            if x != "":
                
                 tunames.append(x)

            x = request.form['tuname2']
           
            if x != "":
                
                 tunames.append(x)

            x = request.form['tuname3']
           
            if x != "":
                 tunames.append(x)
        
            #print "hello" + tunames[0] + tunames[1] + tunames[2]
                
            
            

        
            for x in range(0, len(tunames)):
                if pythontwitter2.tweets.check(tunames[x]) != 1:
                    uerror = "Some of your twitter info isn't valid. Try again."
                    result = 0
                    return render_template('register.html', uerror = uerror)
            if storage.validate(uname, password) == 3:
                if password != "" and fullname != "" and user_hashtag != "" and uname != "" and len(tunames) != 0:
                    result = storage.addUser(uname, password, fullname, tunames, user_hashtag)
                    print storage.addTweets(uname)
                    success = ""
                    print "Your user info:"
                    print storage.getInfo(uname)
                    print storage.getTweets(uname)
                    success = "You succesfully created a new account!"
                    print success
                    #VALUES = {
                     #   'uname': uname,
                      #  'user_hashtag': user_hashtag,
                       #          }
                    return redirect(url_for('instaregister', uname=uname, user_hashtag=user_hashtag))
                #render_template('register.html', terror
            else:
                print "hello" +  tunames[0]
                uerror = "Some of your user info is invalid. Please try again."
                return render_template('register.html', uerror = uerror)