{% extends "./basepage_item.html" %}
{% load i18n humanize %}

{% block title %}
{% if not object.is_published and object.program.is_published %}
    <a href="{{ object.program.get_absolute_url }}">
        {{ object.program.title }}
    </a>
{% else %}
    {{ block.super }}
{% endif %}
{% endblock %}

{% block class %}
{% if object.is_now %}is-active{% endif %}
{% endblock %}

{% block subtitle %}
{% if diffusion %}
    {{ diffusion.start|naturalday }},
    {{ diffusion.start|date:"g:i" }}
{% else %}
    {{ block.super }}
{% endif %}
{% endblock %}


{% block actions %}
{% if object.sound_set.public.count %}
<button class="button" @click="player.playButtonClick($event)"
        data-sounds="{{ object.podcasts|json }}">
    <span class="icon is-small">
        <span class="fas fa-play"></span>
    </span>
</button>
{% endif %}
{% endblock %}

{% block actions %}
{% has_perm page object.program.change_permission_codename simple=True as can_edit %}
{% if can_edit %}
  <a class="button" href="{% url 'episode-edit' object.pk %}" target="_self">
    <span class="icon is-small"><i class="fas fa-pen" alt="{% trans 'edit' %}"></i></span>
  </a>
{% endif %}

{% if object.sound_set.public.count %}
<button class="button" @click="player.playButtonClick($event)"
        data-sounds="{{ object.podcasts|json }}">
    <span class="icon is-small">
        <span class="fas fa-play"></span>
    </span>
</button>
{% endif %}
{% endblock %}
