def site_index(): if is_ta(): return redirect(url_for("ta.index"), code=302) elif user_id(): return redirect(url_for("dashboard.index"), code=302) else: return redirect(url_for("onboarding.log_in"), code=302)
def welcome(): github = github_username() with DbCursor() as c: user = get_user_by_id(c, user_id()) return render_template("onboarding/welcome.html", github=github, user=user, inst_account_enabled=config.inst_account_enabled)
def log_out(): if request.method == "POST": authenticate_as_user(None) authenticate_as_github_username(None) return redirect(url_for("onboarding.log_in")) elif github_username() or user_id(): return render_template("onboarding/log_out.html") else: return redirect(url_for("onboarding.log_in"))
def wrapped(*args, **kwargs): if not user_id(): if request.method == "GET": session["login_next__dashboard"] = request.base_url elif "login_next__dashboard" in session: del session["login_next__dashboard"] return redirect(url_for("onboarding.log_in")) else: if "login_next__dashboard" in session: del session["login_next__dashboard"] return fn(*args, **kwargs)
def assignments(): with DbCursor() as c: c.execute("SELECT assignment, score, slipunits, updated FROM grades WHERE user = ?", [user_id()]) grade_info = {assignment: (score, slipunits, updated) for assignment, score, slipunits, updated in c.fetchall()} template_common = _template_common(c) assignments_info = [(a.name, a.full_score, a.weight, a.due_date) + grade_info.get(a.name, (None, None, None)) for a in config.assignments if now_compare(a.not_visible_before) >= 0] return render_template("dashboard/assignments.html", assignments_info=assignments_info, **template_common)
def assignments(): with DbCursor() as c: c.execute( "SELECT assignment, score, slipunits, updated FROM grades WHERE user = ?", [user_id()]) grade_info = { assignment: (score, slipunits, updated) for assignment, score, slipunits, updated in c.fetchall() } template_common = _template_common(c) assignments_info = [(a.name, a.full_score, a.weight, a.due_date) + grade_info.get(a.name, (None, None, None)) for a in config.assignments if now_compare(a.not_visible_before) >= 0] return render_template("dashboard/assignments.html", assignments_info=assignments_info, **template_common)
def _get_current_step(): if is_ta(): return "ta.index" if user_id(): return "dashboard.index" github = github_username() if not github: return "onboarding.log_in" with DbCursor() as c: user = get_user_by_github(c, github) if not user: return "onboarding.student_id" user_id_, _, _, _, _, _ = user if config.student_photos_enabled: photo = get_photo(c, user_id_) if not photo: return "onboarding.photo" authenticate_as_user(user_id_) return "dashboard.index"
def _get_student(c): if not hasattr(g, "student"): g.student = get_user_by_id(c, user_id()) return g.student