TabbycatDebate/tabbycat

View on GitHub
tabbycat/breakqual/templates/breaking_index.html

Summary

Maintainability
Test Coverage
{% extends "base.html" %}
{% load static debate_tags i18n %}

{% block head-title %}<span class="emoji">👑</span> {% trans "Breaks" %}{% endblock %}
{% block page-title %}{% trans "Breaks" %}{% endblock %}

{% block page-alerts %}
  {% if not categories.exists %}

    {% blocktrans trimmed asvar message %}
      This tournament does not have any break categories set up. You can read
       about how to create breaks
      <a href="https://tabbycat.readthedocs.io/en/stable/features/breaks.html"
          class="alert-link" target="_blank">
        at our documentation.
      </a>
    {% endblocktrans %}
    {% include "components/alert.html" with type="warning" %}

  {% endif %}
{% endblock %}

{% block page-subnav-sections %}
{% include "breakqual_subnav.html" %}
{% endblock %}

{% block page-subnav-actions %}
  <div class="btn-group btn-group">
    <a class="btn btn-outline-primary" href="{% tournamenturl 'break-categories-edit' %}">
      {% trans "Break Categories" %}
    </a>
    <a class="btn btn-outline-primary" href="{% tournamenturl 'breakqual-edit-eligibility' %}">
      {% trans "Team Eligibility" %}
    </a>
  </div>
{% endblock %}

{% block content %}

<div class="row">
  {% with teams_in_tournament=tournament.team_set.count %}
    {% for category in categories %}
      <div class="col-md-4 col mb-3">
        <div class="card">
          <div class="list-group list-group-flush">

            <div class="list-group-item">
              <h4 class="card-title mb-0">
                {% blocktrans trimmed with category=category.name %}
                  {{ category }} Break
                {% endblocktrans %}
              {% blocktrans trimmed with size=category.break_size %}
              <span class="badge float-right badge-light">
                {{ size }} Spots
              </span>
              {% endblocktrans %}
              </h4>
            </div>

            {% if category.nonbreaking == category.eligible %}

              <div class="list-group-item">
                <div class="d-flex justify-content-end">
                  <span class="mr-auto">{% trans "Teams Eligible" %}</span>
                  <strong>{{ category.eligible }}/{{ teams_in_tournament }}</strong>
                </div>
                {% include "components/progress-bar.html" with value=category.eligible total=teams_in_tournament type="secondary" %}
              </div>

            {% else %}

              {% with total=teams_in_tournament %}

                <div class="list-group-item">
                  <div class="d-flex justify-content-end">
                    <span class="mr-auto">{% trans "Breaking" %}</span>
                    <strong>{{ category.breaking }}</strong>
                  </div>
                  {% include "components/progress-bar.html" with value=category.breaking type="success" %}
                </div>

                <div class="list-group-item">
                  <div class="d-flex justify-content-end">
                    <span class="mr-auto">{% trans "Excluded" %}</span>
                    <strong>{{ category.excluded }}</strong>
                  </div>
                  {% include "components/progress-bar.html" with value=category.excluded type="warning" %}
                </div>

                <div class="list-group-item">
                  <div class="d-flex justify-content-end">
                    <span class="mr-auto">{% trans "Eligible" %}</span>
                    <strong>{{ category.eligible }}</strong>
                  </div>
                  {% include "components/progress-bar.html" with value=category.eligible type="info" %}
                </div>

              {% endwith %}

            {% endif %}

            {% if category.eligible == 0 %}
              {% tournamenturl 'breakqual-edit-eligibility' as url %}
              {% trans "Mark teams as eligible" as text %}
              {% include "components/item-action.html" with alone=True type="success" to_complete=True %}
            {% else %}
              {% tournamenturl 'breakqual-teams' category.slug as url %}
              {% if category.breaking == 0 %}
                {% trans "Generate this break" as text %}
                {% include "components/item-action.html" with alone=True type="success" to_complete=True %}
              {% else %}
                {% trans "View this break" as text %}
                {% include "components/item-action.html" with  type="primary" %}
              {% endif %}
            {% endif %}

          </div>
        </div>
      </div>
    {% endfor %}
  {% endwith %}
</div>

{% endblock content %}