{% extends "base.html" %}
{% block title %}Person {{personexpedition.person}} for {{personexpedition.expedition}}{% endblock %}

{% block content %}
<h1>
  <a href="{{personexpedition.person.get_absolute_url}}">{{personexpedition.person|safe}}</a> : 
  <a href="{{personexpedition.expedition.get_absolute_url}}">{{personexpedition.expedition}}</a>
</h1>

<p>{{message}}</p>
<p>{{personexpedition.surveyedleglength|floatformat:1}} m surveyed this year.</p>

<p><b>Other years:&nbsp;</b>
{% for otherpersonexpedition in personexpedition.person.personexpedition_set.all %}
  {% if otherpersonexpedition == personexpedition %}
  | <b>{{otherpersonexpedition.expedition.year}}</b>
  {% else %}
  | <a href="{{otherpersonexpedition.get_absolute_url}}">{{ otherpersonexpedition.expedition.year }}</a>
  {% endif %}
{% endfor %}
</p>
<p>Status of all wallets for <b>
<a href="/wallets/person/{{personexpedition.person.first_name|safe}}{{personexpedition.person.last_name|safe}}">{{personexpedition.person}}</a>
</b>
</p>
<h3>Table of all trips and surveys aligned by date</h3>
<div>
<table class="survexcontibutions">
<tr><th>Date</th><th colspan="2">Trips</th><th colspan="2">Surveys</th></tr>
{% for persondate in personchronology %}
<tr>
  <td class="date">{{persondate.0}}</td>

  {% if persondate.1 %}
     <td width="35%" class="trip"><a href="{{ persondate.1.logbook_entry.get_absolute_url }}">{{persondate.1.logbook_entry.title|safe}}</a></td>
     <td><a href="{{ persondate.1.logbook_entry.cave.get_absolute_url }}"> {{persondate.1.logbook_entry.place|safe}}</a></td>
  {% else %}
     <td colspan="2"> </td>
  {% endif %}

  {% if persondate.2 %}
    <td class="survexblock"><a href="{% url "svx" persondate.2.survexfile.path %}">{{persondate.2.name}}</a></td>
                                   
    <td style="text-align:right">
    {{persondate.2.legslength|floatformat:1}} m
    </td>
  {% else %}
    <td colspan="3"> </td>
  {% endif %}

</tr>
{% endfor %}
</table>
</div>
{% comment %}
<div style="color: slategray; background-color:lightcyan">
<p>Horrible convoluted bug here, but only for some survex files. Mostly, a survex block is duplicated. But not always.

<p>
e.g. see <a href="/personexpedition/Wookey/1999">Wookey 1999</a> where there are one eiscream survex block on 5th August in eiscream.svx
<br>It duplicates it. Also on 4th Aug. there is only one block, but it gets shown twice.

<p>The interaction of django database query idioms with <a href="https://docs.djangoproject.com/en/dev/ref/templates/api/">django HTML templating language</a> is a bit impenetrable here. 
I blame Aaron Curtis who was too fond of being clever with the Django templating system 
instead or writing it in python anyone could understand.<br>
- The template is in <var>troggle/templates/personexpedition.html</var>
<br>
- The code is in function <var>personexpedition()</var> which calls 
<var>get_person_chronology()</var> in <var>troggle/core/views/logbooks.py</var>
<br>
- the connection between the two is made in the URL resolver in <var>troggle/urls.py</var>
<p>To be fixed!
</div>
{% endcomment %}
{% endblock %}