{% load kegweblib %}

{% with tap.current_keg as keg %}

{% if keg %}
<div class="well well-small clickable"
    data-href="{{ keg.get_absolute_url }}">
{% elif user.is_staff %}
<div class="well well-small clickable"
    data-href="{% url 'kegadmin-edit-tap' tap.id %}">
{% else %}
<div class="well well-small">
{% endif %}

  <div class="row-fluid">
    {% if keg.type and keg.type.picture %}
    <div class="span8">
    {% else %}
    <div class="span12">
    {% endif %}
      <h4 style="margin-top: 0px;">
        {% if keg %}
          {{ keg.type.name }} <br/>
          <small>{{ tap.name }}</small>
        {% else %}
          {{ tap.name }}
        {% endif %}
      </h4>

      {% if not keg %}
        <p>
          Tap is offline{% if user.is_staff %} (click to manage){% endif %}.
        </p>

      {% else %}
          {% progress_bar keg.percent_full %}
          &nbsp;{% volume keg.remaining_volume_ml %} remaining

          {% if tap.temperature_sensor %}
          {% with tap.temperature_sensor.LastLog as temp %}
          {% if temp %}
            &middot; {% temperature temp.temp %}
          {% endif %}
          {% endwith %}
          {% endif %}
      {% endif %}

      </div>

      {% if keg.type and keg.type.picture %}
      {% url "kb-keg" keg.id as keg_url %}
      <div class="span4">
        <div style="border: 1px solid #ccc;">
          <a href="{{ keg_url }}">
            <img src="{{ keg.type.picture.resized.url }}"/>
          </a>
        </div>
      </div>
      {% endif %}

  </div> <!-- /row-fluid -->
</div>
{% endwith %}
