def profile(): if request.method == 'GET': page = generate_page( "Welcome to {0}".format(COURSE_NAME), "index", "", "Welcome to CS 196, {0}. You've never before taken a course like this." .format(COURSE_NAME)) unique = db.get_user_details(session['netid']) questions = basic_info.get_questions(unique) return render_template('profile.html', page=page, unique=unique, questions=questions, message=PROFILE_MESSAGE) else: github = request.form['Github'] euler = request.form['Euler'] check_github = urllib.urlopen('https://github.com/{0}'.format(github)) check_euler = True try: Image.open( cStringIO.StringIO( urllib.urlopen( 'https://projecteuler.net/profile/{0}.png'.format( euler)).read())) except IOError: check_euler = False if check_euler and check_github.getcode() == 200: year = request.form['Year'] email = request.form['Email'] phone = request.form['Phone'] skills = request.form['Skills'] wants = request.form['Wants'] db.update_user_details(year, email, github, euler, phone, skills, wants, session['netid']) message = "Thanks a lot! We updated your information." elif not check_euler: message = "We couldn't find your Project Euler account! If you're sure the account exists, email [email protected]" else: message = "We couldn't find your GitHub account! If you're sure the account exists, email [email protected]" page = generate_page( "Welcome to {0}".format(COURSE_NAME), "index", "", "Welcome to CS 196, {0}. You've never before taken a course like this." .format(COURSE_NAME)) unique = db.get_user_details(session['netid']) questions = basic_info.get_questions(unique) return render_template('profile.html', **locals())
def render_profile(): page = generate_page("Profile", "index", "") unique = db.get_user_details(session['netid']) attendance = db.dump_netid_attendance(session['netid']) return render_template('profile.html',page=page,unique=unique, attendance=attendance)
def index(): return redirect('/profile') unique = db.get_user_details(session['netid']) return render_template("index.html", unique=unique, page=generate_page("dashboard", "index", ""))