djbrown/hbscorez

View on GitHub
src/leagues/jinja2/leagues/games.j2

Summary

Maintainability
Test Coverage
{% extends 'leagues/base.j2' %}
{% block title %}Spiele - {{ super() }}{% endblock %}
{% block description %}Spielergebnisse der Liga '{{ league.name }}' des Bereichs '{{ league.district.name }}'{% endblock %}
{% block content %}
{{ super() }}
<nav class="nav nav-pills mb-3">
    <a class="nav-item nav-link m-1" href="{{ url('leagues:detail', args=[league.bhv_id]) }}">Übersicht</a>
    <a class="nav-item nav-link m-1" href="{{ url('leagues:teams', args=[league.bhv_id]) }}">Mannschaften</a>
    <a class="nav-item nav-link m-1 active" href="#/">Spiele</a>
    <a class="nav-item nav-link m-1" href="{{ url('leagues:scorers', args=[league.bhv_id]) }}">Schützen</a>
    <a class="nav-item nav-link m-1" href="{{ url('leagues:offenders', args=[league.bhv_id]) }}">Straffällige</a>
</nav>
<h2>Spiele</h2>
<div class="table-responsive">
    <table id="data-table" class="table table-sm table-striped">
        <caption>Spiele</caption>
        <thead>
        <tr>
            <th scope="col">#</th>
            <th scope="col">Datum</th>
            <th scope="col">Uhrzeit</th>
            <th scope="col">Heimmannschaft</th>
            <th scope="col">Gastmannschaft</th>
            <th scope="col">Ergebnis</th>
            <th scope="col">Heim</th>
            <th scope="col">Gast</th>
            <th scope="col">Halle</th>
            <th scope="col">Zuschauer</th>
            <th scope="col">Bericht</th>
        </tr>
        </thead>
        <tbody>
        {% for game in league.game_set.all().order_by('opening_whistle') %}
        {% set d = date(game.opening_whistle, 'SHORT_DATE_FORMAT') if game.opening_whistle else "-" %}
        {% set t = time(game.opening_whistle) if game.opening_whistle else "-" %}
        <tr>
            <th scope="row">{{ loop.index }}</th>
            <td>{{ d }}</td>
            <td>{{ t if t != "00:00" else "-" }}</td>
            <td>
                {#<img class="table-team-logo" src="{{ team_logo_url(opponent) }}" width="25" alt="HbScorez Logo">#}
                <img class="table-team-logo" src="{{ static('base/images/favicons/favicon.png') }}" width="25"
                     alt="HbScorez Logo"/>
                <a href="{{ game.home_team.get_absolute_url() }}">{{ game.home_team.short_name }}</a>
            </td>
            <td>
                <img class="table-team-logo" src="{{ static('base/images/favicons/favicon.png') }}" width="25"
                     alt="HbScorez Logo"/>
                <a href="{{ game.guest_team.get_absolute_url() }}">{{ game.guest_team.short_name }}</a>
            </td>
            <td>{{ game_outcome_badge(game.outcome())|safe }}</td>
            <td>{{ game.home_goals or "-" }}</td>
            <td>{{ game.guest_goals or "-" }}</td>
            <td><a href="#/">{{ game.sports_hall.name if game.sports_hall else "-" }}</a></td>
            <td>{{ game.spectators or "-" }}</td>
            <td>
                {% if game.report_source_url() %}
                <a href="{{ game.report_source_url() }}">
                    <span class="fas fa-link" title="Datenquelle"></span>
                </a>
                {% else %}
                -
                {% endif %}
            </td>
        </tr>
        {% endfor %}
        </tbody>
        <tfoot>
        <tr>
            <th scope="col">#</th>
            <th scope="col">Datum</th>
            <th scope="col">Uhrzeit</th>
            <th scope="col">Heimmannschaft</th>
            <th scope="col">Gastmannschaft</th>
            <th scope="col">Ergebnis</th>
            <th scope="col">Heim</th>
            <th scope="col">Gast</th>
            <th scope="col">Halle</th>
            <th scope="col">Zuschauer</th>
            <th scope="col">Bericht</th>
        </tr>
        </tfoot>
    </table>
</div>
{% endblock %}