{% extends "aircox/page_detail.html" %}
{% comment %}Detail page of a show{% endcomment %}
{% load i18n aircox %}

{% block top-nav-tools %}
{% has_perm page page.change_permission_codename simple=True as can_edit %}
{% if can_edit %}
<a class="navbar-item" href="{% url 'program-edit' page.pk %}" target="_self">
    <span class="icon is-small">
        <i class="fa fa-pen"></i>
    </span>&nbsp;
    <span>{% translate "Edit" %}</span>
</a>
{% endif %}
{% endblock %}

{% block content-container %}
{% with schedules=program.schedule_set.all %}
{% if schedules %}
<header class="container schedules">
    {% for schedule in schedules %}
    <div class="schedule">
        <div class="heading">
            <span class="day">{{ schedule.get_frequency_display }}</span>
            {% with schedule.start|date:"H:i" as start %}
            {% with schedule.end|date:"H:i" as end %}
            <time datetime="{{ start }}">{{ start }}</time>
            &mdash;
            <time datetime="{{ end }}">{{ end }}</time>
            {% endwith %}
            {% endwith %}
            <small>
                {% if schedule.is_rerun %}
                {% with schedule.initial.date as date %}
                <span title="{% blocktranslate %}Rerun of {{ date }}{% endblocktranslate %}">
                    ({% translate "Rerun" %})
                </span>
                {% endwith %}
                {% endif %}
            </small>
        </div>
    </div>
    {% endfor %}
</header>
{% endif %}
{% endwith %}

{{ block.super }}

{% if episodes %}
<section class="container">
    <h3 class="title">{% translate "Last Episodes" %}</h3>
    {% include "./widgets/carousel.html" with objects=episodes url_name="episode-list" url_parent=object url_label=_("All episodes") %}
</section>
{% endif %}


{% if articles %}
<section class="container">
    <h3 class="title">{% translate "Last Articles" %}</h3>
    {% include "./widgets/carousel.html" with objects=articles url_name="article-list" url_parent=object url_label=_("All articles") %}
</section>
{% endif %}

{% endblock %}
