{% load cms_tags i18n extra_tags %}

{% spaceless %}
{% if course_runs %}
    <ul class="course-detail__run-list">
        {% for run in course_runs %}
            {% if run.is_visible_on_course_page or request.toolbar.edit_mode_active %}
                {% render_model_block run %}
                    <li class="{% if max_course_runs and max_course_runs < forloop.counter %}is-hidden {% endif %}course-detail__run-list--{{ run.catalog_visibility|lower }}">
                        {% if course != run.direct_course %}
                            <a href="{{ run.direct_course.extended_object.get_absolute_url }}">
                        {% endif %}
                        {% if run.title %}
                            {% blocktrans with title=run.title|capfirst start=run.start|date:'DATE_FORMAT'|default:'...' end=run.end|date:'DATE_FORMAT'|default:'...' %}
                                {{ title }}, from {{ start }} to {{ end }}
                            {% endblocktrans %}
                        {% else %}
                            {% blocktrans with start=run.start|date:'DATE_FORMAT'|default:'...' end=run.end|date:'DATE_FORMAT'|default:'...' %}
                                From {{ start }} to {{ end }}
                            {% endblocktrans %}
                        {% endif %}
                        {% if course != run.direct_course %}
                            </a>
                        {% endif %}
                    </li>
                {% endrender_model_block %}
            {% endif %}
        {% endfor %}
    </ul>
    {% if max_course_runs and course_runs|length > max_course_runs %}
        <button type="button" class="course-detail__view-more-runs" onclick="toggleClass(this.previousElementSibling.getElementsByClassName('is-hidden'), 'is-hidden'); toggleClass([this], 'is-hidden');">
            {% trans "View more" %}
        </button>
    {% endif %}
{% endif %}
{% endspaceless %}
