{% load danceschool_tags i18n %}

<a name="{{ event.slug }}-{{ event.id }}">
<div class="card">
  <div class="card-body reg-event"
       id="reg-event-{{ event.id }}">
    <div class="row">
      <div class="col-md-12">
          <h3 class="card-title reg-event-title">{{ event.name }}</h3>
        </a>
        <div class="card-subtitle text-muted reg-event-details">
          {% if event.teachers %}
            {% trans "with" %} {{ event.teachers|join:" &amp; " }}
          {% endif %}
          {% if directions_url %}
            at 
            <a href="{{ directions_url }}#{{ event.location.name|slugify }}">
              {{ event.location.name }}{% if event.room.name %} - {{ event.room.name }}{% endif %}
            </a>
          {% elif event.location or event.room %}
            at {{ event.location.name }}{% if event.room.name %} - {{ event.room.name }}{% endif %}
          {% endif %}

          <div class="card-text reg-event-dates">
            <small>
              {% if event.numOccurrences > 1 %}
                {% readable_weekday event.weekday %}s {{ event.startTime|date:"g:i A" }}
                - {{ event.endTime|date:"g:i A" }} —
                {% for occurrence in event.eventoccurrence_set.all %}
                  {{ occurrence.startTime|date:"N j" }}{% if not forloop.last %}, {% endif %}
                {% endfor %}
              {% else %}
                {{ event.startTime|date:"l, N jS, g:i A" }}
              {% endif %}
            </small>
          </div>

          {% if event.partnerRequired %}
          <div class="card-text reg-partner-required">{% trans "Partner required" %}</div>
          {% endif %}

          {% if event.url %}
            <small><a href="{{ event.url }}">{% trans "more info" %}</a></small>
          {% endif %}
        </div>
      </div>
      <div class="col-lg-8 col-md-6">
        {% if showDescriptionRule == "all" %}
          {{ event.classDescription.description }}
        {% elif showDescriptionRule != "0" %}
          {{ event.classDescription.description|truncatewords_html:showDescriptionRule }}
        {% endif %}
        <div class="card-text reg-event-pricing mt-4">
          {% if event.pricingTier and event.registrationOpen %}
            <a class="pricingPopover seriestype"
               data-container="body"
               data-toggle="popover"
               data-placement="bottom"
               title="<strong>{{ event.pricingTier.name }}</strong>"
               data-html="true"
               href="#"
               data-trigger="hover"
               data-content="<em>{% trans 'Pre-Registered' %}</em><br />


                       {{ currencySymbol }}{{ event.pricingTier.onlinePrice|floatformat:2 }}<br /><em>{% trans 'At the Door' %}</em><br />
                       {{ currencySymbol }}{{ event.pricingTier.doorPrice|floatformat:2 }}"
            >{{ event.pricingTier.name }}</a>
          {% endif %}
        </div>
      </div>
      <div class="col-lg-4 col-md-6 ml-md-auto mt-4 mt-md-0 reg-event-register">
        {% if event.registrationOpen %}
          {# if event registration is still open then show the registration form#}
          {% get_field_for_object event.polymorphic_ctype.model event.id form as field %}
          {{ field }}
          {% if validationStr %}
            <div class="alert alert-danger">
              {{ field.errors }}
            </div>
          {% endif %}
        {% else %}
          {# else show the number of registrants#}
          <ul class="list-unstyled">
            {% for role in event.availableRoles %}
              <li>{{ role.pluralName }} ({% numRegisteredForRole event role %} {% trans "registered" %})</li>
            {% empty %}
              <li>({{ event.numRegistered }} {% trans "registered" %})</li>
            {% endfor %}
          </ul>
        {% endif %}
      </div>
      {% if event.soldOut %}
        <div class="col-12 reg-event-soldout">
          <h5 class="card-title">{% trans "Sold Out!" %}</h5>
        </div>
        {% if perms.core.override_register_closed %}
          <div class="col-auto">
            {# Include the front desk admin button #}

            {% get_field_for_object event.polymorphic_ctype.model event.id form as field %}
            {{ field }}
            {% if validationStr %}
              <div class="alert alert-danger">
                {{ field.errors }}
              </div>
            {% endif %}
          </div>
        {% endif %}
      {% endif %}
    </div>
  </div>
</div>
