Skip to content

Commit e0533d4

Browse files
committed
Add dedicated Practice / Contest Scoreboard buttons
Fixes #214
1 parent df6895b commit e0533d4

16 files changed

+55
-39
lines changed

src/application.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,8 @@ def problems():
678678
categories.sort(key=lambda x: x['category'])
679679

680680
is_ongoing_contest = len(db.execute(
681-
("SELECT id AS n FROM contests WHERE end > datetime('now') AND "
682-
"start <= datetime('now') ORDER BY end DESC")))
681+
"SELECT * FROM contests WHERE end > datetime('now') AND start <= datetime('now')"
682+
))
683683

684684
return render_template('problem/problems.html',
685685
data=data, solved=solved, length=-(-length // 50),
@@ -786,7 +786,13 @@ def profile(username):
786786
@app.route("/ranking")
787787
def ranking():
788788
user_info = db.execute("SELECT * FROM users WHERE verified=1 ORDER BY total_points DESC")
789-
return render_template("ranking.html", user_data=user_info)
789+
790+
is_ongoing_contest = len(db.execute(
791+
"SELECT * FROM contests WHERE end > datetime('now') AND start <= datetime('now')"
792+
))
793+
794+
return render_template("ranking.html", user_data=user_info,
795+
is_ongoing_contest=is_ongoing_contest)
790796

791797

792798
# Error handling

src/templates/contest/contest.html

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
1-
{% extends "layout.html" %}
1+
{% extends "contest/layout.html" %}
22

33
{% block title %}{{ title }}{% endblock %}
44
{% block active %}Contests{% endblock %}
55

66
{% block main %}
77
<div style="position: relative; margin-bottom: 0.5rem;">
88
<h1 style="display: inline;">{{ title }}</h1>
9-
{% if scoreboard or check_perm(["ADMIN", "SUPERADMIN"]) %}
9+
{% if check_perm(["ADMIN", "SUPERADMIN"]) %}
1010
<div class="dropdown" style="display: inline; margin-left: 4px;">
1111
<button class="btn btn-secondary dropdown-toggle" type="button"
1212
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
1313
style="margin-top: -18px;">Actions</button>
1414
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
15-
{% if scoreboard %}
16-
<a class="dropdown-item" href="{{ request.path }}/scoreboard">Scoreboard</a>
17-
{% endif %}
18-
{% if check_perm(["ADMIN", "SUPERADMIN"]) %}
19-
<a class="dropdown-item"
20-
href="/admin/submissions?contest_id={{ request.path[9:] }}">Submissions</a>
21-
<a class="dropdown-item"
22-
href="{{ request.path }}/addproblem">Add Problem</a>
23-
<a class="dropdown-item"
24-
href="{{ request.path }}/drafts">View Draft Problems</a>
25-
<a class="dropdown-item"
26-
href="{{ request.path }}/notify">Notify Participants</a>
27-
<a class="dropdown-item"
28-
href="/api/contest/scoreboard/{{ request.path[9:] }}?key={{ scoreboard_key }}">Export CTFtime Scoreboard</a>
29-
{% endif %}
15+
<a class="dropdown-item"
16+
href="/admin/submissions?contest_id={{ request.path[9:] }}">Submissions</a>
17+
<a class="dropdown-item"
18+
href="{{ request.path }}/addproblem">Add Problem</a>
19+
<a class="dropdown-item"
20+
href="{{ request.path }}/drafts">View Draft Problems</a>
21+
<a class="dropdown-item"
22+
href="{{ request.path }}/notify">Notify Participants</a>
23+
<a class="dropdown-item"
24+
href="/api/contest/scoreboard/{{ request.path[9:] }}?key={{ scoreboard_key }}">Export CTFtime Scoreboard</a>
3025
</div>
3126
</div>
3227
{% endif %}

src/templates/contest/contest_problem.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "layout.html" %}
1+
{% extends "contest/layout.html" %}
22

33
{% block title %}{{ data["name"] }}{% endblock %}
44
{% block active %}Contests{% endblock %}

src/templates/contest/contest_problem_noexist.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "layout.html" %}
1+
{% extends "contest/layout.html" %}
22

33
{% block title %}Nonexistent problem{% endblock %}
44
{% block active %}Contests{% endblock %}

src/templates/contest/create_problem.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "layout.html" %}
1+
{% extends "contest/layout.html" %}
22

33
{% block title %}Create Problem{% endblock %}
44
{% block active %}Contests{% endblock %}

src/templates/contest/draft_problems.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "layout.html" %}
1+
{% extends "contest/layout.html" %}
22

33
{% block title %}{{ title }} Draft Problems{% endblock %}
44
{% block active %}Contests{% endblock %}

src/templates/contest/edit_problem.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "layout.html" %}
1+
{% extends "contest/layout.html" %}
22

33
{% block title %}Edit {{ data["name"] }}{% endblock %}
44
{% block active %}Contests{% endblock %}

src/templates/contest/export_problem.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "layout.html" %}
1+
{% extends "contest/layout.html" %}
22

33
{% block title %}Export {{ data["name"] }}{% endblock %}
44
{% block active %}Contests{% endblock %}

src/templates/contest/layout.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% extends "layout.html" %}
2+
3+
{% block contest_leaderboard %}
4+
<li><a class="nav-link" href="{{ '/'.join(request.path.split('/')[:3]) }}/scoreboard">Contest Leaderboard</a></li>
5+
{% endblock %}

src/templates/contest/notify.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "layout.html" %}
1+
{% extends "contest/layout.html" %}
22

33
{% block title %}Notify Participants{% endblock %}
44
{% block active %}Contests{% endblock %}

0 commit comments

Comments
 (0)