예제 #1
0
파일: __init__.py 프로젝트: aykamko/ob2
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)
예제 #2
0
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)
예제 #3
0
파일: __init__.py 프로젝트: aykamko/ob2
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)
예제 #4
0
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)
예제 #5
0
파일: __init__.py 프로젝트: aykamko/ob2
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"))
예제 #6
0
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"))
예제 #7
0
파일: __init__.py 프로젝트: octobear2/ob2
 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)
예제 #8
0
파일: __init__.py 프로젝트: samkumar/ob2
 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)
예제 #9
0
파일: __init__.py 프로젝트: octobear2/ob2
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)
예제 #10
0
파일: __init__.py 프로젝트: samkumar/ob2
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)
예제 #11
0
파일: __init__.py 프로젝트: aykamko/ob2
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"
예제 #12
0
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"
예제 #13
0
파일: __init__.py 프로젝트: octobear2/ob2
def _get_student(c):
    if not hasattr(g, "student"):
        g.student = get_user_by_id(c, user_id())
    return g.student
예제 #14
0
파일: __init__.py 프로젝트: samkumar/ob2
def _get_student(c):
    if not hasattr(g, "student"):
        g.student = get_user_by_id(c, user_id())
    return g.student