djbrown/hbscorez

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

Summary

Maintainability
Test Coverage
{% extends 'teams/base.j2' %}
{% block title %}Spiele - {{ super() }}{% endblock %}
{% block description %}Spielergebnisse der Mannschaft '{{ team.name }}' in der Liga '{{ team.league.name }}' des
    Bereichs '{{ team.league.district.name }}'{% endblock %}
{% block content %}
    {{ super() }}
    <nav class="nav nav-pills mb-3">
        <a class="nav-item nav-link m-1" href="{{ url('teams:detail', args=[team.bhv_id]) }}">Übersicht</a>
        <a class="nav-item nav-link m-1 active" href="#/">Spiele</a>
        <a class="nav-item nav-link m-1" href="{{ url('teams:players', args=[team.bhv_id]) }}">Spieler</a>
        <a class="nav-item nav-link m-1" href="{{ url('teams:scorers', args=[team.bhv_id]) }}">Schützen</a>
        <a class="nav-item nav-link m-1" href="{{ url('teams:offenders', args=[team.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">Gegner</th>
                <th scope="col">Ergebnis</th>
                <th scope="col">Tore</th>
                <th scope="col">Gegentore</th>
                <th scope="col">Halle</th>
                <th scope="col">Zuschauer</th>
                <th scope="col">Bericht</th>
            </tr>
            </thead>
            <tbody>
            {% for game in games %}
                {% set opponent = game.opponent_of(team) %}
                {% 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="{{ opponent.get_absolute_url() }}">{{ opponent.short_name }}</a>
                    </td>
                    <td>{{ team_outcome_badge(game.outcome_for(team))|safe }}</td>
                    <td>{{ game.goals_of(team) if game.goals_of(team) != None else "-" }}</td>
                    <td>{{ game.goals_of(opponent) if game.goals_of(opponent)!= None else "-" }}</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">Gegner</th>
                <th scope="col">Ergebnis</th>
                <th scope="col">Tore</th>
                <th scope="col">Gegentore</th>
                <th scope="col">Halle</th>
                <th scope="col">Zuschauer</th>
                <th scope="col">Bericht</th>
            </tr>
            </tfoot>
        </table>
    </div>
{% endblock %}