Skip to content

Commit

Permalink
Display bracket names for teams & users (#96)
Browse files Browse the repository at this point in the history
* Theme related PR for CTFd/CTFd#2612
* Displays brackets on public and private pages for users/teams
  • Loading branch information
ColdHeat authored Oct 2, 2024
1 parent 2e64dda commit 4a4f687
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 13 deletions.
13 changes: 13 additions & 0 deletions templates/teams/private.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ <h3 class="d-inline-block">
</h3>
{% endif %}

{% if team.bracket_id %}
<div class="pt-2">
<h2>
<span class="badge text-bg-light">
{{ team.bracket.name }}
</span>
</h2>
</div>
{% endif %}

{% for field in team.fields %}
<h3 class="d-block">
{{ field.name }}: {{ field.value }}
Expand Down Expand Up @@ -328,6 +338,9 @@ <h3>{% trans %}Members{% endtrans %}</h3>
<a href="{{ url_for('users.public', user_id=member.id) }}">
{{ member.name }}
</a>
{% if member.bracket_id %}
<span class="badge bg-secondary ms-2">{{ member.bracket.name }}</span>
{% endif %}
{% if team.captain_id == member.id %}
<span class="badge bg-primary ms-2">{% trans %}Captain{% endtrans %}</span>
{% endif %}
Expand Down
26 changes: 21 additions & 5 deletions templates/teams/public.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,23 @@ <h3 class="d-inline-block mx-1">

{% if team.country %}
<h3 class="d-inline-block mx-1">
<span class="badge bg-primary rounded-pill">
<i class="flag-{{ team.country.lower() }}"></i>
{{ lookup_country_code(team.country) }}
</span>
<span class="badge bg-primary rounded-pill">
<i class="flag-{{ team.country.lower() }}"></i>
{{ lookup_country_code(team.country) }}
</span>
</h3>
{% endif %}

{% if team.bracket_id %}
<div class="pt-2">
<h2>
<span class="badge text-bg-light">
{{ team.bracket.name }}
</span>
</h2>
</div>
{% endif %}

<div class="pt-2">
{% for field in team.fields %}
<h3 class="d-block">
Expand All @@ -51,7 +61,7 @@ <h3 class="d-block">

<h2 id="team-place" class="text-center">
{# This intentionally hides the team's place when scores are hidden because this can be
their internal profile and we don't want to leak their place in the CTF. #}
their internal profile and we don't want to leak their place in the CTF. #}

{# Public page hiding is done at the route level #}
{% if scores_visible() %}
Expand Down Expand Up @@ -93,6 +103,12 @@ <h3>{% trans %}Members{% endtrans %}</h3>
<a href="{{ url_for('users.public', user_id=member.id) }}">
{{ member.name }}
</a>
{% if member.bracket_id %}
<span class="badge bg-secondary ms-2">{{ member.bracket.name }}</span>
{% endif %}
{% if team.captain_id == member.id %}
<span class="badge bg-primary ms-2">{% trans %}Captain{% endtrans %}</span>
{% endif %}
</td>
<td>{{ member.score }}</td>
</tr>
Expand Down
4 changes: 4 additions & 0 deletions templates/teams/teams.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ <h6 class="text-muted text-center pb-3">
<span>{{ team.name | truncate(50) }}</span>
{% endif %}

{% if team.bracket_id %}
<span class="badge bg-secondary ms-2">{{ team.bracket.name }}</span>
{% endif %}

{% if team.oauth_id %}
<a href="https://majorleaguecyber.org/t/{{ team.name }}">
<span class="badge bg-primary ms-2">Official</span>
Expand Down
10 changes: 10 additions & 0 deletions templates/users/private.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ <h3 class="d-inline-block mx-1">
{% endif %}
</div>

{% if user.bracket_id %}
<div class="pt-2">
<h2>
<span class="badge text-bg-light">
{{ user.bracket.name }}
</span>
</h2>
</div>
{% endif %}

<div class="pt-2">
{% for field in user.fields %}
<h3 class="d-block">
Expand Down
26 changes: 18 additions & 8 deletions templates/users/public.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ <h1>{{ user.name }}</h1>
{% if user.team_id %}
<h2>
<a href="{{ url_for('teams.public', team_id=user.team_id) }}">
<span class="badge bg-secondary">
{{ user.team.name }}
</span>
<span class="badge bg-secondary">
{{ user.team.name }}
</span>
</a>
</h2>
{% endif %}
Expand Down Expand Up @@ -38,6 +38,16 @@ <h3 class="d-inline-block mx-1">
{% endif %}
</div>

{% if user.bracket_id %}
<div class="pt-2">
<h2>
<span class="badge text-bg-light">
{{ user.bracket.name }}
</span>
</h2>
</div>
{% endif %}

<div class="pt-2">
{% for field in user.fields %}
<h3 class="d-block">
Expand Down Expand Up @@ -211,11 +221,11 @@ <h3 class="opacity-50 text-center w-100 justify-content-center align-self-center
{% block scripts %}
<script>
window.USER = {{ {
'type': 'user',
'id': user.id,
'name': user.name,
'account_id': user.id,
} | tojson }};
'type': 'user',
'id': user.id,
'name': user.name,
'account_id': user.id,
} | tojson }};
</script>

{{ Assets.js("assets/js/users/public.js") }}
Expand Down
4 changes: 4 additions & 0 deletions templates/users/users.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ <h6 class="text-muted text-center pb-3">
<span>{{ user.name | truncate(50) }}</span>
{% endif %}

{% if user.bracket_id %}
<span class="badge bg-secondary ms-2">{{ user.bracket.name }}</span>
{% endif %}

{% if user.oauth_id %}
<a href="https://majorleaguecyber.org/u/{{ user.name }}">
<span class="badge bg-primary ms-2">{% trans %}Official{% endtrans %}</span>
Expand Down

0 comments on commit 4a4f687

Please sign in to comment.