예제 #1
0
def Rate(yourGroup=None,questions=questions):
    if request.method=='GET':
        if 'user' in session:
            try:
                email = str(session['user'])
                yourGroup = util.getGroup(email)
                print yourGroup #debug
                return render_template('rate.html',groupmembers=yourGroup,questions=questions)
            except:
                return render_template('rate.html',groupmembers=["*****@*****.**"],questions=questions)
        else:
            return redirect(url_for("login"))
    else:
        submit = request.form['submit']
 #       option = request.form['option']
#        if submit == 'submit':
        for i in util.getGroup(str(session['user'])):
            for j in range(11):
                k=str(j)
                r = request.form[str(i+','+k)]
                rate.append(r)
                print r
            util.giveRating(session['user'],i,rate)
            rate = []
#        radio = request.form['radio']
#        for i in range (len(questions)):
#            print radio[i]
#            r = radio[i]
        #    rate = rate + r
        return redirect(url_for('home'))
예제 #2
0
def rateother():
    if request.method=='GET':
        return render_template('rateother.html')
    else:
        button=request.form['button']
        ratee=request.form['ratee']
        q1=int(request.form['q1'])
        q2=int(request.form['q2'])
        q3=int(request.form['q3'])
        q4=int(request.form['q4'])
        if button == 'Save':
            group = util.getGroup(session['email'])
            if group.count(str(ratee)) == 0:
                redirect(url_for('error'))
            if q1 < 1 or q1 > 10:
                redirect(url_for('error'))
            if q2 < 1 or q2 > 10:
                redirect(url_for('error'))
            if q3 < 1 or q3 > 10:
                redirect(url_for('error'))
            if q4 < 1 or q4 > 10:
                redirect(url_for('error'))
            ratings = [q1,q2,q3,q4]
            util.setRate(session['email'], ratee, 'Project 1', ratings)
            redirect(url_for('results'))
        elif button == 'Cancel':
            redirect(url_for('results'))
import util

print "Testing Login Authorization"
print util.loginAuthorized('*****@*****.**',8680)

print util.getGroup('*****@*****.**')
print util.getInfo('*****@*****.**')

q=9
print (q > 10 or q <0)
ratings = [q, 6, 8]
print ratings


util.setRate('*****@*****.**','*****@*****.**','Project 1',ratings)

print str(util.getAllMyRatings('*****@*****.**'))

util.setRate('*****@*****.**','*****@*****.**','Project 1', [8, 5, 9])
util.setRate('*****@*****.**','*****@*****.**', 'Project 1', 5)

print str(util.getAllMyRatings('*****@*****.**'))
print str(util.getAllMyRatings('*****@*****.**'))