{% extends "detail.html" %}
{% load boolicontag %}

{% block content %}
<table class="table table-hover">
  <tr>
    <th colspan="2">Physical</th>
  </tr>
  {% if object.manufacturer is not None %}
  <tr>
    <td>Manufacturer</td>
    <td><a href="{% url 'manufacturer-detail' object.manufacturer.slug %}">{{ object.manufacturer }}</a></td>
  </tr>
  {% endif %}
  <tr>
    <td>Model</td>
    <td>{{ object.model }}</td>
  </tr>
  {% if object.disambiguation is not None %}
  <tr>
    <td>Disambiguation</td>
    <td>{{ object.disambiguation }}</td>
  </tr>
  {% endif %}
  {% if object.mount is not None %}
  <tr>
    <td>Mount</td>
    <td><a href="{% url 'mount-detail' object.mount.slug %}">{{ object.mount }}</a></td>
  </tr>
  {% endif %}
  {% if object.introduced is not None %}
  <tr>
    <td>Marketed</td>
    <td>{{ object.introduced }}{% if object.discontinued is not None %}-{{ object.discontinued }}{% endif %}</td>
  </tr>
  {% endif %}
  {% if object.weight is not None %}
  <tr>
    <td>Weight</td>
    <td>{{ object.weight }}g</td>
  </tr>
  {% endif %}
  {% if object.length is not None %}
  <tr>
    <td>Length</td>
    <td>{{ object.length }}mm</td>
  </tr>
  {% endif %}
  {% if object.diameter is not None %}
  <tr>
    <td>Diameter</td>
    <td>{{ object.diameter }}mm</td>
  </tr>
  {% endif %}


  <tr>
    <th colspan="2">Optics</th>
  </tr>
  {% if object.zoom is not None %}
  <tr>
    <td>Zoom</td>
    <td>{{ object.zoom|boolicontag }}</td>
  </tr>
  {% endif %}
  {% if object.min_focal_length is not None %}
  <tr>
    <td>Focal length</td>
    <td>
      {{ object.min_focal_length }}{% if object.zoom is not False and object.max_focal_length is not None %}-{{ object.max_focal_length }}{% endif %}mm
    </td>
  </tr>
  {% endif %}
  {% if object.zoom_ratio is not None %}
  <tr>
    <td>Zoom ratio</td>
    <td>{{ object.zoom_ratio }}&times;</td>
  </tr>
  {% endif %}
  {% if object.max_aperture is not None %}
  <tr>
    <td>Aperture</td>
    <td>
      <em>f</em>/{{ object.max_aperture }}{% if object.min_aperture is not None %}-{{ object.min_aperture }}{% endif %}
    </td>
  </tr>
  {% endif %}
  {% if object.closest_focus is not None %}
  <tr>
    <td>Closest focus</td>
    <td>{{ object.closest_focus }}m</td>
  </tr>
  {% endif %}
  {% if object.elements is not None and object.groups is not None %}
  <tr>
    <td>Elements/Groups</td>
    <td>{{ object.elements }}/{{ object.groups }}</td>
  </tr>
  {% else %}
  {% if object.elements is not None %}
  <tr>
    <td>Elements</td>
    <td>{{ object.elements }}</td>
  </tr>
  {% endif %}
  {% if object.groups is not None %}
  <tr>
    <td>Groups</td>
    <td>{{ object.groups }}</td>
  </tr>
  {% endif %}
  {% endif %}
  {% if object.nominal_max_angle_diag is not None %}
  <tr>
    <td>Diagonal angle of view</td>
    <td>
      {{ object.nominal_max_angle_diag }}{% if object.zoom is not False and object.nominal_min_angle_diag is not None %}-{{ object.nominal_min_angle_diag }}{% endif %}&deg;
    </td>
  </tr>
  {% endif %}
  {% if object.rectilinear is not None %}
  <tr>
    <td>Rectilinear</td>
    <td>{{ object.rectilinear|boolicontag }}</td>
  </tr>
  {% endif %}
  {% if object.magnification is not None %}
  <tr>
    <td>Maximum magnification</td>
    <td>{{ object.magnification }}&times;</td>
  </tr>
  {% endif %}
  {% if object.negative_size is not None %}
  <tr>
    <td>Negative size</td>
    <td><a href="{% url 'negativesize-detail' object.negative_size.id %}">{{ object.negative_size }}</a></td>
  </tr>
  {% endif %}
  {% if object.aperture_blades is not None %}
  <tr>
    <td>Aperture blades</td>
    <td>{{ object.aperture_blades }}</td>
  </tr>
  {% endif %}
  {% if object.image_circle is not None %}
  <tr>
    <td>Image circle</td>
    <td>{{ object.image_circle }}mm</td>
  </tr>
  {% endif %}


  <tr>
    <th colspan="2">Features</th>
  </tr>
  {% if object.autofocus is not None %}
  <tr>
    <td>Autofocus</td>
    <td>{{ object.autofocus|boolicontag }}</td>
  </tr>
  {% endif %}
  {% if object.filter_thread is not None %}
  <tr>
    <td>Filter thread</td>
    <td>{{ object.filter_thread }}mm</td>
  </tr>
  {% endif %}
  {% if object.coating is not None %}
  <tr>
    <td>Coating</td>
    <td>{{ object.coating }}</td>
  </tr>
  {% endif %}
  {% if object.hood is not None %}
  <tr>
    <td>Hood</td>
    <td>{{ object.hood }}</td>
  </tr>
  {% endif %}
  {% if object.shutter_model is not None %}
  <tr>
    <td>Shutter model</td>
    <td>{{ object.shutter_model }}</td>
  </tr>
  {% endif %}


  <tr>
    <th colspan="2">Misc</th>
  </tr>
  {% if object.notes is not None %}
  <tr>
    <td>Notes</td>
    <td>{{ object.notes }}</td>
  </tr>
  {% endif %}
  {% if object.tags is not None %}
  <tr>
    <td>Tags</td>
    <td>{% for tag in object.tags.all %}
      <a class="btn btn-outline-primary" href="{% url 'tag-detail' tag|lower %}" role="button">{{ tag }}</a>
      {% endfor %}</td>
  </tr>
  {% endif %}
  {% if object.url is not None %}
  <tr>
    <td>URL</td>
    <td><a href="{{ object.url }}">{{ object.url }}</a></td>
  </tr>
  {% endif %}
  {% if object.created_at is not None %}
  <tr>
    <td>Created</td>
    <td>{{ object.created_at }}{% if object.created_by is not None %} by {{ object.created_by }}{% endif %}</td>
  </tr>
  {% endif %}
  {% if object.updated_at is not None %}
  <tr>
    <td>Last updated</td>
    <td>{{ object.updated_at }}{% if object.updated_by is not None %} by {{ object.updated_by }}{% endif %}</td>
  </tr>
  {% endif %}
</table>

{% if related %}
<h4>Similar lens models</h4>
<ul>
  {% for relateditem in related %}
  <li><a href="{% url 'lensmodel-detail' relateditem.slug %}">{{ relateditem }}</a></li>
  {% endfor %}
</ul>
{% endif %}

{% if user.is_authenticated %}
{% if mine %}
<h4>In your collection</h4>

<table class="table table-hover">
  <tr>
    <th>ID</th>
    <th>Serial</th>
    <th>Manufactured</th>
    <th>Own</th>
  </tr>
  {% for lens in mine %}
  <tr>
    <td><a href="{% url 'lens-detail' lens.id_owner %}">#{{ lens.id_owner }}</a></td>
    <td>{% if lens.serial is not None %}<code>{{ lens.serial }}</code>{% endif %}</td>
    <td>{% if lens.manufactured is not None %}{{ lens.manufactured }}{% endif %}</td>
    <td>{% if lens.own is not None %}{{ lens.own|boolicontag }}{% endif %}</td>
  </tr>
  {% endfor %}
</table>
{% endif %}
{% endif %}
{% endblock %}

{% block moreactions %}
<form action="{% url 'lens-create' %}">
  <input type="hidden" name="lensmodel" value="{{ object.id }}">
  <button class="btn btn-primary" type="submit">Add to collection</button>
</form>
{% endblock %}
