Link directly to users from the submissions page in teams mode (#1823)

* Links directly to users who submitted something in the submissions page if the CTF is in teams mode. 
* Closes #1813
This commit is contained in:
Kevin Chung
2021-03-16 15:32:38 -04:00
committed by GitHub
parent 1e0b196189
commit a3dbecdd18
4 changed files with 21 additions and 13 deletions

View File

@@ -33,17 +33,7 @@ def submissions_listing(submission_type):
Model = get_model()
submissions = (
Submissions.query.add_columns(
Submissions.id,
Submissions.type,
Submissions.challenge_id,
Submissions.provided,
Submissions.account_id,
Submissions.date,
Challenges.name.label("challenge_name"),
Model.name.label("account_name"),
)
.filter_by(**filters_by)
Submissions.query.filter_by(**filters_by)
.filter(*filters)
.join(Challenges)
.join(Model)

View File

@@ -13,6 +13,12 @@ class ConfigTypes(str, RawEnum):
REGISTRATION_VISIBILITY = "registration_visibility"
@JinjaEnum
class UserModeTypes(str, RawEnum):
USERS = "users"
TEAMS = "teams"
@JinjaEnum
class ChallengeVisibilityTypes(str, RawEnum):
PUBLIC = "public"

View File

@@ -57,6 +57,7 @@
</div>
<div class="row">
<div class="col-md-12">
{% set mode = Configs.user_mode %}
<table id="teamsboard" class="table table-striped border">
<thead>
<tr>
@@ -66,6 +67,9 @@
</div>
</th>
<th class="text-center sort-col"><b>ID</b></th>
{% if mode == UserModeTypes.TEAMS %}
<th class="sort-col"><b>User</b></th>
{% endif %}
<th class="sort-col"><b>{{ get_mode_as_word(capitalize=True) }}</b></th>
<th class="sort-col"><b>Challenge</b></th>
<th class="sort-col"><b>Type</b></th>
@@ -84,14 +88,21 @@
<td class="text-center" id="{{ sub.id }}">
{{ sub.id }}
</td>
{% if mode == UserModeTypes.TEAMS %}
<td>
<a href="{{ url_for('admin.users_detail', user_id=sub.user_id) }}">
{{ sub.user.name }}
</a>
</td>
{% endif %}
<td class="team" id="{{ sub.account_id }}">
<a href="{{ generate_account_url(sub.account_id, admin=True) }}">
{{ sub.account_name }}
{{ sub.account.name }}
</a>
</td>
<td class="chal" id="{{ sub.challenge_id }}">
<a href="{{ url_for('admin.challenges_detail', challenge_id=sub.challenge_id) }}">
{{ sub.challenge_name }}
{{ sub.challenge.name }}
</a>
</td>
<td>

View File

@@ -3,6 +3,7 @@ from flask import url_for
from CTFd.models import Teams, Users
from CTFd.utils import get_config
# TODO: Replace these constants with the UserModeTypes enum
USERS_MODE = "users"
TEAMS_MODE = "teams"