TabbycatDebate/tabbycat

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

Summary

Maintainability
Test Coverage
{% extends "tables/base_vue_table.html" %}
{% load static debate_tags i18n add_field_css %}

{% block head-title %}{% blocktrans trimmed with category=category.name %}
  {{ category }} Break
{% endblocktrans %}{% endblock %}
{% block sub-title %}
  {% if pref.public_breaking_teams %}
    {% trans "publicly visible" %}
  {% else %}
    {% trans "not publicly visible" %}
  {% endif %}
{% endblock %}
{% block page-title %}👑 {% blocktrans trimmed with category=category.name %}
  {{ category }} Break
{% endblocktrans %}{% endblock %}

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

{% block page-subnav-actions %}
  {% if generated %}
    <form action="{% tournamenturl 'breakqual-generate-all' category.slug %}" class="form-inline" method="POST">
      {% csrf_token %}
      <button class="btn btn-danger" id="generateBreakingTeams" type="submit">
        {% trans "Delete and Regenerate All Breaks" %} <i data-feather="repeat"></i>
      </button>
    </form>
  {% else %}
    <div class="forms-block-inline">
      <form action="{% tournamenturl 'breakqual-generate-all' category.slug %}" method="POST">
        {% csrf_token %}
        <button class="btn btn-{{ pref.public_breaking_teams|yesno:"danger,success" }} form-control"
                id="generateBreakingTeams" type="submit">
          {% trans "Generate the Break for All Categories" %} <i data-feather="chevron-right"></i>
        </button>
      </form>
    </div>
  {% endif %}
{% endblock %}

{% block page-alerts %}

  {% if category.team_set.count == 0 %}

    {% tournamenturl 'breakqual-edit-eligibility' as url %}
    {% blocktrans trimmed asvar message %}
    There are <strong>0 teams marked as eligible</strong> for this category — you will need to
       <a href="{{ url }}" class="alert-link">
      add some eligible teams</a> for this break to generate correctly.
    {% endblocktrans %}
    {% include "components/alert.html" with type="warning" %}

  {% endif %}

  {% if generated %}

    {% url 'admin:breakqual_breakcategory_change' category.id as url %}
    {% blocktrans trimmed asvar p1 with category=category.get_rule_display %}
      This break uses the <strong>{{ category }}</strong> rule — if you intended to use a different rule, you should <a href="{{ url }}"> edit the rule for this break category in the Edit Database area</a>, then delete and regenerate all breaks. Please double-check this before announcing the break or releasing it to the public. The code that generates the break is not robustly tested for corner cases.
    {% endblocktrans %}
    {% include "components/explainer-card.html" with type="warning" %}

    {% url 'admin:breakqual_breakingteam_changelist' as url %}
    {% blocktrans trimmed asvar p1 %}
      To edit the break use the remarks in the right-hand column. Any team with a remark will be excluded from this break (the break generator will sometimes insert its own remarks). Then, click the appropriate Save Remarks and Update button below. If you have complicated break rules (for example, if some teams are allowed to choose their preferred category) then you may have to update remarks a few times to get the correct break. As a last resort, you can <a href="{{ url }}"> edit the breaking teams list directly in the Edit Database area</a>.
    {% endblocktrans %}
    {% include "components/explainer-card.html" with type="info" %}

  {% else %}
    {% if pref.public_breaking_teams %}
      <div class="alert alert-danger">
        <i data-feather="alert-circle"></i>
        {% tournamenturl 'options-tournament-index' as options_url %}
        {% blocktrans trimmed %}
          The <strong>public breaking teams</strong> configuration setting is
          enabled. As soon as you click the button, the breaking teams list will
          be visible on the public site, before you have a chance to
          double-check it! It is strongly recommended that you disable this
          setting on the <a href="{{ options_url }}">
          tournament configuration page</a> before generating the team
          breaks.
        {% endblocktrans %}
      </div>
    {% else %}

      {% blocktrans trimmed asvar p1 %}
        The break hasn't yet been generated. Would you like to generate the break for all categories? It's safe to generate the break before all preliminary rounds are complete, if you're curious — you can regenerate it later.
      {% endblocktrans %}
      {% include "components/explainer-card.html" with type="info" %}

    {% endif %}
  {% endif %}
{% endblock %}

{% block content %}
{% if generated %}
  <form action="." method="POST">

    {% csrf_token %}

    {{ block.super }}

    {% if pref.public_breaking_teams %}

      {% blocktrans trimmed asvar message %}
        <strong>Caution!</strong> The "public breaking teams" option is turned on, so the break
        is publicly visible. If you update the break(s), the changes will become visible
        <strong>immediately</strong>, <strong>without a chance for you to review them</strong>.
      {% endblocktrans %}
      {% include "components/alert.html" with type="danger" %}

    {% endif %}

    <div class="card">
      <div class="card-body row">
        <div class="form-inline col-md-6">
          <button class="btn btn-primary btn-block btn-success" type="submit" name="save_update_all">
            {% trans "Save Remarks and Update All Breaks" %}
          </button>
        </div>
        <div class="form-inline col-md-6">
          <button class="btn btn-primary btn-block btn-success" type="submit" name="save_update_one">
            {% blocktrans trimmed with category=category.name %}
              Save Remarks and Update the {{ category }} Break
            {% endblocktrans %}
          </button>
        </div>
      </div>
    </div>

  </form>
{% else %}
  <div id="vueMount"></div><!-- Prevent unfound item error for Vue -->
  {% tournamenturl 'breakqual-edit-eligibility' as url %}
  {% blocktrans trimmed asvar text with count=category.team_set.count %}
    There are <strong>{{ count }} teams marked as eligible</strong> for this
    category. Would you like to add more eligible teams?
  {% endblocktrans %}
  {% include "components/item-action.html" with type="primary" url=url to_complete=true %}

{% endif %}
{% endblock content %}