예제 #1
0
def login():
    global groupsize
    global currentCounter
    global MembersofGroup
    global email
    global IDList
    if request.method=='GET':
        return render_template("homepage.html")
    else:

        button = request.form['button']
        if button == 'Rate':
            print "HI"
            email = request.form["username"]
            if storage.checkUser(email)==True:
                IDList = storage.getInfo(email)
                MembersofGroup = storage.returnGroupList(email)
                groupsize = len(MembersofGroup)
                currentCounter = 0
                return redirect(url_for("rate"))
            else:
                return redirect(url_for("page_not_found"))
        elif button == 'Get Ratings!':
            email = request.form["username"]
            if storage.checkUser(email)==True:
                IDList = storage.getInfo(email)
                MembersofGroup = storage.returnGroupList(email)
                currentCounter = 0
                return redirect(url_for("viewRates"))
            else:
                return redirect(url_for("page_not_found"))
        else:
            return redirect(url_for("page_not_found"))
예제 #2
0
def instagram():
    print 'start'
    #global uname
    #global user_hashtag
    uname = request.args.get('uname')
    user_hashtag = storage.getHash(uname)
    print request.args.keys()
    print uname
    print user_hashtag
    print request.args.get('code')
    try:
        code = request.args.get('code')
    except:
        res = "Missing Code, Please try again"
        return redirect(url_for('instaregister', res = res, uname=uname))
    try:
        print '1'
        code = request.args.get('code')
        print code
        print api
        access_token, instagram_user = api.exchange_code_for_access_token(code)
        print '2'
        print access_token
    except:
        res = "No token, please try again"
        return redirect(url_for('instaregister', res = res, uname = uname))
    user_id = instagram_user['id']
    user_token = access_token
    result = storage.addInstagram(uname, user_token, user_id)
    print user_id + user_hashtag + result
    taggedimages = instagramhub.get_pics(user_id, user_token, user_hashtag)
    photo = taggedimages[0]
    print "Your username" + uname
    print storage.getInfo(uname)
    storage.addTweets(uname)
    tweets = storage.getTweets(uname)
    print tweets
    #print "Here are your tweets" + tweets
    print taggedimages
    return render_template('instagram.html', tweets = tweets, images = taggedimages, user_hashtag = user_hashtag, photo = photo)
예제 #3
0
def rate():
    global email
    global IDList
    global MembersofGroup
    global currentCounter
    global groupsize
    if request.method == 'GET':   
        return render_template('RatingPage.html',currentRatee =storage.getInfo( MembersofGroup[currentCounter])[0])
    else:
        if request.form["button"] == "Rate":
            
            r1 = str(request.form["rating1"])
            r2 = str(request.form["rating2"])
            r3 = str(request.form["rating3"])
            r4 = str(request.form["rating4"])
            comment = str(request.form["comment"])
            storage.addRating(email,storage.getInfo( MembersofGroup[currentCounter])[0],r1,r2,r3,r4,comment)
            currentCounter = currentCounter+1
            if currentCounter < groupsize:
                return redirect(url_for('rate',currentRatee = MembersofGroup[currentCounter]))
            
            else:
                return redirect(url_for('Success'))
예제 #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)