Allow selecting single users to view

This commit is contained in:
2024-02-16 00:18:55 +01:00
parent 26acc22e84
commit 516fa107e5
3 changed files with 58 additions and 16 deletions

View File

@ -3,7 +3,7 @@
{# Easy nav-bar entries. When a page sets the active_page variable, the current entry will be underlined #}
{% macro nav_selector(page='', text='') %}
<a class="nav-link" href="/{{ page }}">{% if active_page == page %}<u>{% endif %} {{ text }}
<a class="nav-link text-nowrap" href="/{{ page }}">{% if active_page == page %}<u>{% endif %} {{ text }}
{% if active_page == page %}</u>{% endif %}</a>
{% endmacro %}
@ -110,18 +110,28 @@
<a class="navbar-brand" href="/">
<img src="../static/image/f1_logo.svg" alt="Logo" width="120" height="30"
class="d-inline-block align-text-top">
Formula <i>10</i> - 2024
Formula <i>10</i>
</a>
<button type="button" class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#navbarCollapse">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<div class="navbar-nav">
<div class="navbar-nav me-2">
{{ nav_selector("race", "Guess Race") }}
{{ nav_selector("season", "Guess Season") }}
{{ nav_selector("graphs", "Statistics") }}
{{ nav_selector("rules", "Rules") }}
</div>
{% block navbar_center %}{% endblock navbar_center %}
<div class="flex-grow-1"></div>
<div class="navbar-nav">
{{ nav_selector("enter", "Enter Race Result") }}
{{ nav_selector("users", "Manage Users") }}
</div>
</div>
</div>
</nav>

View File

@ -2,7 +2,22 @@
{% set active_page = "race" %}
{% block title %}Formula 10{% endblock title %}
{% block title %}Formula 10 - Race{% endblock title %}
{% block navbar_center %}
<div class="dropdown">
<button class="btn btn-outline-danger dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
{{ chosenusername }}
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/race/Everyone">Everyone</a></li>
<li><hr class="dropdown-divider"></li>
{% for user in users %}
<li><a class="dropdown-item" href="/race/{{ user.name }}">{{ user.name }}</a></li>
{% endfor %}
</ul>
</div>
{% endblock navbar_center %}
{% block body %}
@ -10,7 +25,7 @@
<thead>
<tr>
<th scope="col" rowspan="2" class="text-center">Race</th>
<th scope="col" colspan="{{ users | length }}" class="text-center">Call</th>
<th scope="col" colspan="{{ chosenusers | length }}" class="text-center">Call</th>
<th scope="col" rowspan="2" class="text-center">Result</th>
</tr>
</thead>
@ -21,7 +36,7 @@
<tr>
<td>&nbsp;</td>
{% for user in users %}
{% for user in chosenusers %}
<td class="text-center text-nowrap">{{ user.name }}</td>
{% endfor %}
@ -33,7 +48,7 @@
<tr class="table-light">
<td class="text-nowrap"><span class="fw-bold">{{ nextrace.id }}:</span> {{ nextrace.grandprix }}</td>
{% for user in users %}
{% for user in chosenusers %}
<td>
<form action="/guessrace/{{ nextrace.id }}/{{ user.name }}" method="post">
{# Driver PXX Select #}
@ -73,7 +88,7 @@
<td class="text-nowrap"><span
class="fw-bold">{{ raceresult.race.id }}:</span> {{ raceresult.race.grandprix }}</td>
{% for user in users %}
{% for user in chosenusers %}
<td class="text-center text-nowrap">
{% if (raceresult.race_id in pastguesses) and (user.name in pastguesses.get(raceresult.race_id)) %}
{% set pxx = pastguesses.get(raceresult.race_id).get(user.name).pxx.abbr %}

View File

@ -2,13 +2,30 @@
{% set active_page = "season" %}
{% block title %}Formula 10{% endblock title %}
{% block title %}Formula 10 - Season{% endblock title %}
{% block navbar_center %}
<div class="dropdown">
<button class="btn btn-outline-danger dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
{{ chosenusername }}
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/season/Everyone">Everyone</a></li>
<li><hr class="dropdown-divider"></li>
{% for user in users %}
<li><a class="dropdown-item" href="/season/{{ user.name }}">{{ user.name }}</a></li>
{% endfor %}
</ul>
</div>
{% endblock navbar_center %}
{% block body %}
<h4 class="heading-text text-danger text-center">All fields (of a single user, excluding podiums) must be set or your inputs won't be saved!</h4>
<div class="grid" style="grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));">
{% for user in users %}
<div class="card mb-2 shadow-sm">
{% for user in chosenusers %}
<div class="card mb-2 shadow-sm" style="width: 450px;">
<div class="card-body">
<h5 class="card-title">{{ user.name }}</h5>
<form action="/guessseason/{{ user.name }}" method="post">
@ -24,31 +41,31 @@
{# P2 Constructor #}
<div class="mt-2">
{{ team_select_with_preselect(currentselection.get(user.name).p2_constructor.name if user.name in currentselection else "",
"p2select", "P2 Constructor:") }}
"p2select", "P2 Constructor:") }}
</div>
{# Most Overtakes #}
<div class="mt-2">
{{ driver_select_with_preselect(currentselection.get(user.name).most_overtakes.abbr if user.name in currentselection else "",
"overtakeselect", "Most Overtakes:") }}
"overtakeselect", "Most Overtakes:") }}
</div>
{# Most DNFs #}
<div class="mt-2">
{{ driver_select_with_preselect(currentselection.get(user.name).most_dnfs.abbr if user.name in currentselection else "",
"dnfselect", "Most DNFs:") }}
"dnfselect", "Most DNFs:") }}
</div>
{# Most Gained #}
<div class="mt-2">
{{ driver_select_with_preselect(currentselection.get(user.name).most_gained.abbr if user.name in currentselection else "",
"gainedselect", "Most Championship Positions gained:") }}
"gainedselect", "Most Championship Positions gained:") }}
</div>
{# Most Lost #}
<div class="mt-2">
{{ driver_select_with_preselect(currentselection.get(user.name).most_lost.abbr if user.name in currentselection else "",
"lostselect", "Most Championship Positions lost:") }}
"lostselect", "Most Championship Positions lost:") }}
</div>
{# Team-internal Winners #}