def scoreboard(contest_name): if session.get_current_user().privilege not in (UserPrivilege.ADMIN, UserPrivilege.TUTOR): return abort(403) contest = Contest.from_name(contest_name) return render_template("scoreboard.html", contest=contest)
def user_view(username): user = User.from_username(username) if user.privilege == UserPrivilege.STANDARD and user != session.get_current_user( ): return abort(403) contests = Contest.of_user(user) return render_template("user.html", user=user, contests=contests)
def submission_view(submission_id): current_user = get_current_user() submission = Submission.from_id(submission_id) if current_user is None or current_user.id != submission.user.id: return abort(403) return render_template('submission.html', goals=submission.goals, user=current_user, id=submission.id)
def contest_view(contest_name): contest = Contest.from_name(contest_name) if contest is None: return abort(404) user = session.get_current_user() if not contest.public and not contest.contains_user(user): return abort(403) return render_template("contest.html", contest=contest, user=user)
def subscribe(contest_name): contest = Contest.from_name(contest_name) user = session.get_current_user() if contest is None: return abort(404) if user is None or not contest.public: return abort(403) contest.add_user(user) return redirect(url_for("contest.contest_view", contest_name=contest_name))
def home(): user = get_current_user() if user is None: return redirect(url_for("user.login")) contests = list(Contest.of_user(user)) available_contests = [ contest for contest in Contest.contests() if contest.public and contest not in contests ] return render_template("home.html", contests=contests, available_contests=available_contests, user=user)
def problem_view(contest_name, name): contest = Contest.from_name(contest_name) if contest is None: return abort(404) current_user = get_current_user() if contest is None or not contest.contains_user(current_user): return abort(403) if request.method == "POST" and current_user is None: return abort(401) problem = Problem.from_name(name) if problem is None: return abort(404) error = None if request.method == "POST": try: return evaluate(current_user, problem, contest) except RuntimeError as e: error = str(e) subs = list( Submission.from_user_and_problem_and_contest(current_user, problem, contest)) correct_goals = { sub.id: sum(val for val in sub.goals.values() if val is not None) for sub in subs } return render_template("problem.html", correct_goals=correct_goals, error=error, problem=problem, contest=contest, user=current_user, submissions=subs)
def download(submission_id, filename): sub = Submission.from_id(submission_id) if get_current_user().id != sub.user_id: return abort(403) assert sub.filename == filename return send_file(sub.path)
def user_(): user = session.get_current_user() if user is not None: return redirect(url_for("user.user_view", username=user.username)) return redirect(url_for("user.login"))