diff --git a/src/application.py b/src/application.py index fd96e58..807c51b 100644 --- a/src/application.py +++ b/src/application.py @@ -678,8 +678,8 @@ def problems(): categories.sort(key=lambda x: x['category']) is_ongoing_contest = len(db.execute( - ("SELECT id AS n FROM contests WHERE end > datetime('now') AND " - "start <= datetime('now') ORDER BY end DESC"))) + "SELECT * FROM contests WHERE end > datetime('now') AND start <= datetime('now')" + )) return render_template('problem/problems.html', data=data, solved=solved, length=-(-length // 50), @@ -786,7 +786,13 @@ def profile(username): @app.route("/ranking") def ranking(): user_info = db.execute("SELECT * FROM users WHERE verified=1 ORDER BY total_points DESC") - return render_template("ranking.html", user_data=user_info) + + is_ongoing_contest = len(db.execute( + "SELECT * FROM contests WHERE end > datetime('now') AND start <= datetime('now')" + )) + + return render_template("ranking.html", user_data=user_info, + is_ongoing_contest=is_ongoing_contest) # Error handling diff --git a/src/templates/contest/contest.html b/src/templates/contest/contest.html index 6519908..475dd56 100644 --- a/src/templates/contest/contest.html +++ b/src/templates/contest/contest.html @@ -1,4 +1,4 @@ -{% extends "layout.html" %} +{% extends "contest/layout.html" %} {% block title %}{{ title }}{% endblock %} {% block active %}Contests{% endblock %} @@ -6,27 +6,22 @@ {% block main %}

{{ title }}

- {% if scoreboard or check_perm(["ADMIN", "SUPERADMIN"]) %} + {% if check_perm(["ADMIN", "SUPERADMIN"]) %} {% endif %} diff --git a/src/templates/contest/contest_problem.html b/src/templates/contest/contest_problem.html index 51eccab..b05a1a0 100644 --- a/src/templates/contest/contest_problem.html +++ b/src/templates/contest/contest_problem.html @@ -1,4 +1,4 @@ -{% extends "layout.html" %} +{% extends "contest/layout.html" %} {% block title %}{{ data["name"] }}{% endblock %} {% block active %}Contests{% endblock %} diff --git a/src/templates/contest/contest_problem_noexist.html b/src/templates/contest/contest_problem_noexist.html index db49224..de68b19 100644 --- a/src/templates/contest/contest_problem_noexist.html +++ b/src/templates/contest/contest_problem_noexist.html @@ -1,4 +1,4 @@ -{% extends "layout.html" %} +{% extends "contest/layout.html" %} {% block title %}Nonexistent problem{% endblock %} {% block active %}Contests{% endblock %} diff --git a/src/templates/contest/create_problem.html b/src/templates/contest/create_problem.html index e146777..4154591 100644 --- a/src/templates/contest/create_problem.html +++ b/src/templates/contest/create_problem.html @@ -1,4 +1,4 @@ -{% extends "layout.html" %} +{% extends "contest/layout.html" %} {% block title %}Create Problem{% endblock %} {% block active %}Contests{% endblock %} diff --git a/src/templates/contest/draft_problems.html b/src/templates/contest/draft_problems.html index f85c40a..8f5c052 100644 --- a/src/templates/contest/draft_problems.html +++ b/src/templates/contest/draft_problems.html @@ -1,4 +1,4 @@ -{% extends "layout.html" %} +{% extends "contest/layout.html" %} {% block title %}{{ title }} Draft Problems{% endblock %} {% block active %}Contests{% endblock %} diff --git a/src/templates/contest/edit_problem.html b/src/templates/contest/edit_problem.html index c687302..b8e203d 100644 --- a/src/templates/contest/edit_problem.html +++ b/src/templates/contest/edit_problem.html @@ -1,4 +1,4 @@ -{% extends "layout.html" %} +{% extends "contest/layout.html" %} {% block title %}Edit {{ data["name"] }}{% endblock %} {% block active %}Contests{% endblock %} diff --git a/src/templates/contest/export_problem.html b/src/templates/contest/export_problem.html index 30dcdd2..e878e33 100644 --- a/src/templates/contest/export_problem.html +++ b/src/templates/contest/export_problem.html @@ -1,4 +1,4 @@ -{% extends "layout.html" %} +{% extends "contest/layout.html" %} {% block title %}Export {{ data["name"] }}{% endblock %} {% block active %}Contests{% endblock %} diff --git a/src/templates/contest/layout.html b/src/templates/contest/layout.html new file mode 100644 index 0000000..c127ee3 --- /dev/null +++ b/src/templates/contest/layout.html @@ -0,0 +1,5 @@ +{% extends "layout.html" %} + +{% block contest_leaderboard %} +
  • Contest Leaderboard
  • +{% endblock %} \ No newline at end of file diff --git a/src/templates/contest/notify.html b/src/templates/contest/notify.html index c2b20e3..a04b2d5 100644 --- a/src/templates/contest/notify.html +++ b/src/templates/contest/notify.html @@ -1,4 +1,4 @@ -{% extends "layout.html" %} +{% extends "contest/layout.html" %} {% block title %}Notify Participants{% endblock %} {% block active %}Contests{% endblock %} diff --git a/src/templates/contest/scoreboard.html b/src/templates/contest/scoreboard.html index ccd4eae..39f76ff 100644 --- a/src/templates/contest/scoreboard.html +++ b/src/templates/contest/scoreboard.html @@ -1,7 +1,7 @@ -{% extends "layout.html" %} +{% extends "contest/layout.html" %} {% block title %}{{ title }} Scoreboard{% endblock %} -{% block active %}Contests{% endblock %} +{% block active %}Contest Leaderboard{% endblock %} {% block main %}

    {{ title }}

    diff --git a/src/templates/layout.html b/src/templates/layout.html index 2d14f3f..0983f95 100644 --- a/src/templates/layout.html +++ b/src/templates/layout.html @@ -27,8 +27,9 @@