Files
flask-formula10/formula10/templates/season.jinja
Christoph Urlacher e8c8e35e05
All checks were successful
Build Formula10 Docker Image / build-docker (push) Successful in 11s
Disable info cards regarding season picks
2024-12-08 19:57:24 +01:00

185 lines
13 KiB
Django/Jinja

{% extends 'base.jinja' %}
{% block title %}Formula 10 - Season{% endblock title %}
{% set active_page = "/season/" ~ model.active_user_name_sanitized_or_everyone() %}
{% block navbar_center %}
{{ active_user_dropdown(page='season') }}
{% endblock navbar_center %}
{% block body %}
{# <div class="card shadow-sm mb-2">#}
{# <div class="card-header">#}
{# Note#}
{# </div>#}
{##}
{# <div class="card-body">#}
{# Picks that match the current standings are marked in green, except for the hot-take and overtake picks, as#}
{# those are not evaluated automatically.<br>#}
{# </div>#}
{# </div>#}
<div class="grid card-grid">
{% for user in model.all_users_or_active_user() %}
<div class="card shadow-sm mb-2">
<div class="card-header">
{# Link should only be visible if all users are visible #}
{% if model.active_user is not none %}
{{ user.name }}
{% else %}
<a href="/season/{{ user.name }}" class="link-dark">{{ user.name }}</a>
{% endif %}
</div>
<div class="card-body">
{% set user_guess = model.season_guesses_by(user_name=user.name) %}
{% set season_guess_open = model.season_guess_open() %}
{% if season_guess_open == true %}
{% set action_save_href = "/season-guess/" ~ user.name %}
{% else %}
{% set action_save_href = "" %}
{% endif %}
<form action="{{ action_save_href }}" method="post">
{# Hot Take #}
<div class="form-floating">
<textarea
class="form-control {% if points.hot_take_correct(user.name) %}border-success{% else %}border-danger{% endif %}"
id="hot-take-input-{{ user.name }}" name="hottakeselect"
style="height: 150px"
{% if season_guess_open == false %}disabled="disabled"{% endif %}>
{%- if user_guess is not none -%}{{ user_guess.hot_take_string() }}{%- endif -%}
</textarea>
<label for="hot-take-input-{{ user.name }}" class="text-primary">Hot Take:</label>
</div>
{# P2 Constructor #}
<div class="mt-2">
{{ team_select_with_preselect(team_match=user_guess.p2_wcc, name="p2select", label="P2 in WCC:",
include_none=false, disabled=not season_guess_open,
border=("border-success" if points.p2_constructor_correct(user.name) else "border-danger")) }}
</div>
{# Most Overtakes + DNFs #}
<div class="input-group mt-2">
{{ driver_select_with_preselect(driver_match=user_guess.most_overtakes, name="overtakeselect",
label="Most overtakes:", include_none=false, include_inactive=true, disabled=not season_guess_open,
border=("border-success" if points.overtakes_correct(user.name) else "border-danger")) }}
{{ driver_select_with_preselect(driver_match=user_guess.most_dnfs, name="dnfselect", label="Most DNFs:",
include_none=false, include_inactive=true, disabled=not season_guess_open,
border=("border-success" if points.dnfs_correct(user.name) else "border-danger")) }}
</div>
{# Most Gained + Lost #}
<div class="input-group mt-2" data-bs-toggle="tooltip"
title="Which driver will gain/lose the most places in comparison to last season's results?">
{{ driver_select_with_preselect(driver_match=user_guess.most_wdc_gained, name="gainedselect",
label="Most WDC pl. gained:", include_none=false, include_inactive=true,
drivers=model.active_drivers_for_wdc_gained(), disabled=not season_guess_open,
border=("border-success" if points.most_gained_correct(user.name) else "border-danger")) }}
{{ driver_select_with_preselect(driver_match=user_guess.most_wdc_lost, name="lostselect",
label="Most WDC pl. lost:", include_none=false, include_inactive=true, disabled=not season_guess_open,
border=("border-success" if points.most_lost_correct(user.name) else "border-danger")) }}
</div>
{# Team-internal Winners #}
<h6 class="card-subtitle mt-2" data-bs-toggle="tooltip"
title="Which driver will finish the season higher than his teammate?">Teammate battle
winners:</h6>
<div class="grid mt-2 container" style="row-gap: 0;">
{% for team in model.all_teams(include_none=false) %}
{# HACK: Choosing 0 and 1 will chose the drivers with the lowest IDs (although there could be others). #}
{# This means the drivers chosen from at the start of the season will be visible. #}
{% set driver_a = model.drivers_by(team_name=team.name, include_inactive=True)[0] %}
{% set driver_b = model.drivers_by(team_name=team.name, include_inactive=True)[1] %}
<div class="g-col-6">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio"
name="teamwinner-{{ team.id }}"
id="teamwinner-{{ team.id }}-1-{{ user.id }}"
value="{{ driver_a.id }}"
{% if (user_guess is not none) and (driver_a in user_guess.team_winners) %}checked="checked"{% endif %}
{% if season_guess_open == false %}disabled="disabled"{% endif %}>
<label class="form-check-label {% if (user_guess is not none) and (driver_a in user_guess.team_winners) and points.is_team_winner(driver_a) %}text-success
{% elif (user_guess is not none) and (driver_a in user_guess.team_winners) and (not points.is_team_winner(driver_a)) %}text-danger{% endif %}"
for="teamwinner-{{ team.id }}-1-{{ user.id }}">{{ driver_a.name }}</label>
</div>
</div>
<div class="g-col-6">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio"
name="teamwinner-{{ team.id }}"
id="teamwinner-{{ team.id }}-2-{{ user.id }}"
value="{{ driver_b.id }}"
{% if (user_guess is not none) and (driver_b in user_guess.team_winners) %}checked="checked"{% endif %}
{% if season_guess_open == false %}disabled="disabled"{% endif %}>
<label class="form-check-label {% if (user_guess is not none) and (driver_b in user_guess.team_winners) and points.is_team_winner(driver_b) %}text-success
{% elif (user_guess is not none) and (driver_b in user_guess.team_winners) and (not points.is_team_winner(driver_b)) %}text-danger{% endif %}"
for="teamwinner-{{ team.id }}-2-{{ user.id }}">{{ driver_b.name }}</label>
</div>
</div>
{% endfor %}
</div>
{# Drivers with Podiums #}
<h6 class="card-subtitle mt-2" data-bs-toggle="tooltip"
title="Which driver will reach at least a single podium?">Drivers with podium(s):</h6>
<div class="grid mt-2 container" style="row-gap: 0;">
{% for team in model.all_teams(include_none=false) %}
{# HACK: Choosing 0 and 1 will chose the drivers with the lowest IDs (although there could be others). #}
{# This means the drivers chosen from at the start of the season will be visible. #}
{% set driver_a = model.drivers_by(team_name=team.name, include_inactive=True)[0] %}
{% set driver_b = model.drivers_by(team_name=team.name, include_inactive=True)[1] %}
<div class="g-col-6">
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox"
name="podiumdrivers"
id="podium-{{ driver_a.id }}-{{ user.id }}"
value="{{ driver_a.id }}"
{% if (user_guess is not none) and (driver_a in user_guess.podiums) %}checked="checked"{% endif %}
{% if season_guess_open == false %}disabled="disabled"{% endif %}>
<label class="form-check-label {% if (user_guess is not none) and (driver_a in user_guess.podiums) and points.has_podium(driver_a) %}text-success
{% elif (user_guess is not none) and (driver_a in user_guess.podiums) and (not points.has_podium(driver_a)) %}text-danger
{% elif (user_guess is not none) and (driver_a not in user_guess.podiums) and (points.has_podium(driver_a)) %}text-danger{% endif %}"
for="podium-{{ driver_a.id }}-{{ user.id }}">{{ driver_a.name }}</label>
</div>
</div>
<div class="g-col-6">
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox"
name="podiumdrivers"
id="podium-{{ driver_b.id }}-{{ user.id }}"
value="{{ driver_b.id }}"
{% if (user_guess is not none) and (driver_b in user_guess.podiums) %}checked="checked"{% endif %}
{% if season_guess_open == false %}disabled="disabled"{% endif %}>
<label class="form-check-label {% if (user_guess is not none) and (driver_b in user_guess.podiums) and points.has_podium(driver_b) %}text-success
{% elif (user_guess is not none) and (driver_b in user_guess.podiums) and (not points.has_podium(driver_b)) %}text-danger
{% elif (user_guess is not none) and (driver_b not in user_guess.podiums) and (points.has_podium(driver_b)) %}text-danger{% endif %}"
for="podium-{{ driver_b.id }}-{{ user.id }}">{{ driver_b.name }}</label>
</div>
</div>
{% endfor %}
</div>
<input type="submit" class="btn btn-danger mt-2 w-100" value="Save"
{% if season_guess_open == false %}disabled="disabled"{% endif %}>
</form>
</div>
</div>
{% endfor %}
</div>
{% endblock body %}