def ratings_page(): global globalemail """ I don't really feel like doing the thing Z talked about in class for this so I'll just hardcode stuff. Might do some fancy visualization stuff with d3.js if I have time and feel like it- this is pretty barebones. """ f = open("questions.txt", "r").readlines() if len(database.getRatings(globalemail))==0: return render_template("ratings.html", q1="No ratings for you yet!") q1ans = "" q2ans = "" q3ans = "" q4ans = "" for rating in database.getRatings(globalemail): q1ans += str(rating[0]) + " " q2ans += str(rating[1]) + " " q3ans += str(rating[2]) + " " q4ans += str(rating[3]) + " " return render_template("ratings.html", q1=f[0], q1ans=q1ans, q2=f[1], q2ans=q2ans, q3=f[2], q3ans=q3ans, q4=f[3], q4ans=q4ans)
def view_ratings(): if session['username'] == "": flash("Please enter a valid username on the home page.") return redirect(url_for("home")) if request.method == "GET": user = session['username'] name = database.getName(str(user)) #note: we have no idea why str(user) is necessary. user should not be unicode. questions = open("questions.txt", "r").readlines() return render_template("view_ratings.html", username = user, first = name[0], last = name[1], ratings = database.getRatings(user), questions = questions) else: button = request.form["button"] if button == "Cancel": session['username'] = "" return redirect(url_for("home")) elif button == "Post Ratings": return redirect(url_for("post_ratings"))
import shelve import database auth = shelve.open("authen") print auth["*****@*****.**"] #groups = shelve.open("groups") #print groups["*****@*****.**"] #print database.getRatings("*****@*****.**") """ f = open("questions.txt", "r").readlines()0 print f[0].strip() print f[0] """ #print database.getGroupMembers("*****@*****.**") #database.addRating("*****@*****.**", "*****@*****.**", [5, 4, 3, 1]) print database.getRatings("*****@*****.**") print database.getRatings("*****@*****.**")