{% extends "podcast_analyzer/app_base.html" %}
{% load i18n %}
{% block extratitle %}{{ podcast.title }} - {% endblock %}

{% block breadcrumbs %}

  <li><a href="{% url 'podcast_analyzer:person-list' %}">{% translate "People" %}</a></li>
  <li class='is-active'><a href="{{ person.get_absolute_url }}" aria-current="page">{{ person.name }}</a> </li>

{% endblock breadcrumbs %}

{% block extra_controls %}
  <div><a href="{% url 'podcast_analyzer:person-edit' id=person.id %}">{% translate "Edit" %}</a> | <a href="{% url 'podcast_analyzer:person-merge-list' id=person.id %}">{% translate "Merge with another record" %}</a></div>
{% endblock extra_controls %}

{% block content %}
  <h1>{{ person.name }}</h1>
  <div>
    <article>
      <figure>
        <p>
          {% if person.img_url %}
            <img src="{% if person.avatar %}{{ person.avatar.url }}{% else %}{{ person.img_url }}{% endif %}" alt="Avatar for {{ person.name }}" height=200 width=200 />
          {% endif %}
        </p>
        {% if person.url %}<p><a href="{{ person.url }}">{% translate "Website" %}</a></p>{% endif %}
      </figure>
    </article>
  </div>
  <div>


    <h2>{% translate "Overall Appearance Statistics" %}</h2>
    <table>
      <thead>
        <tr>
          <td>{% translate "Type" %}</td>
          <td>{% translate "As Host" %}</td>
          <td>{% translate "As Guest" %}</td>
          <td>{% translate "Total" %}</td>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>{% translate "Podcasts" %}</td>
          <td>{{ person.hosted_podcasts }}</td>
          <td>{{ person.guested_podcasts }}</td>
          <td>{{ person.distinct_podcasts }}</td>
        </tr>
        <tr>
          <td>{% translate "Episodes" %}</td>
          <td>{{ person.has_hosted }}</td>
          <td>{{ person.has_guested }}</td>
          <td>{{ person.get_total_episodes }}</td>
        </tr>
      </tbody>
    </table>

    <h2>{% translate "Podcast Appearances" %}</h2>
    <table>
      <thead>
        <tr>
          <td>{% translate "Podcast" %}</td>
          <td>{% translate "Hosted episodes" %}</td>
          <td>{% translate "Guested episodes" %}</td>
        </tr>
      </thead>
      <tbody>
        {% for pod_data in person.get_podcasts_with_appearance_counts %}
          <tr>
            <td><a href="{{ pod_data.podcast.get_absolute_url }}">{{ pod_data.podcast.title }}</a></td>
            <td>{{ pod_data.hosted_episodes.count }}</td>
            <td>{{ pod_data.guested_episodes.count }}</td>
          </tr>
        {% empty %}
          <tr>
            <td>{% translate "No appearances yet." %}</td>
            <td></td>
            <td></td>
          </tr>
        {% endfor %}
      </tbody>
    </table>

  </div>

  <div>
    <div>

      <a href="{% url 'podcast_analyzer:person-edit' id=person.id %}">{% translate "Edit" %}</a>
    </div>
    <div>

      <a href="{% url 'podcast_analyzer:person-delete' id=person.id %}">{% translate "Delete person" %}</a>
    </div>

  </div>

{% endblock content %}
