{% extends "base.html" %}
{% load kegweblib %}

{% block title %}Drink {{ drink.id }} by {% drinker_name drink nolink %} | {{ block.super }}{% endblock %}
{% block pagetitle %}Drink {{ drink.id }} by {% drinker_name drink %}{% endblock %}

{% block content %}

{% if user.is_staff %}
<div id="cancelModal" class="modal hide fade" tabindex="-1"
    role="dialog" aria-labelledby="cancelDialogLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="cancelDialogLabel">Really Delete Drink {{ drink.id }}?</h3>
    </div>
    <div class="modal-body">
        <p>
            Are you sure you want to cancel <b>Drink {{ drink.id }}</b>{% if drink.user %} by <b>{{ drink.user }}</b>{% endif %}?
        </p>
        <p>
            Deleting the drink will <b>immediately delete the drink and all data about it</b>, including
            any pictures recorded during the pour.  This action cannot be undone.
        </p>
    </div>
    <div class="modal-footer">
         <form action="{% url "kegadmin-edit-drink" drink.id %}" method="POST">{% csrf_token %}
         <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
             <input type="submit" name="submit_cancel"
                class="btn btn-danger" value="Delete Drink"/>
         </form>
    </div>
</div>
{% endif %}

<div class="row-fluid">

<div class="span6">

<table class="table table-striped">
<tbody>
  <tr>
    <th>Size</th>
    {% if user.is_staff %}
    <td>
      <form action="{% url 'kegadmin-edit-drink' drink.id %}" method="POST">{% csrf_token %}
      <div class="input-prepend input-append">
        {% if kbsite.settings.volume_display_units == 'metric' %}
          <input type="hidden" name="units" value="mL">
          <input class="span4" type="text" name="volume" value="{{ drink.volume_ml|floatformat:2 }}">
          <span class="add-on">mL</span>
        {% else %}
          <input type="hidden" name="units" value="oz">
          <input class="span4" type="text" name="volume" value="{{ drink.volume_ml|volume:'ounces'|floatformat:2 }}">
          <span class="add-on">oz</span>
        {% endif %}
        <button class="btn btn-warning" name="submit_edit_volume" type="submit">
          <i class="icon-pencil icon-white"></i> Resize
        </button>
      </div>
      </form>
    </td>
    {% else %}
    <td>
      {% volume drink.volume_ml %}
      {% if drink.duration %}
      <span class="muted">
       (took {{drink.duration}} second{{drink.duration|pluralize}} to pour)
      </span>
      {% endif %}
    </td>
    {% endif %}
  </tr>

  <tr>
    <th>When</th>
    <td>
       {% timeago drink.time %}
    </td>
  </tr>

  {% if drink.keg %}
  <tr>
    <th>Keg</th>
    <td>
      <a href="{% url "kb-keg" drink.keg.id %}">{{drink.keg.type.name}}</a>
    </td>
  </tr>
  {% endif %}

  <tr>
    <th>Session</th>
    <td>
       <a href="{{ drink.session.get_absolute_url }}">{{ drink.session.GetTitle }}</a>
       <span class="muted">({{ drink.session.summarize_drinkers|safe }})</span>
    </td>
  </tr>

  <tr>
    <th>Permalink</th>
    <td>
       <a href="{{ drink.ShortUrl }}">{{ drink.ShortUrl }}</a>
    </td>
  </tr>

  </tbody>
</table>

{% if user.is_staff %}
<h3>Manager Controls</h3>
      <form action="{% url "kegadmin-edit-drink" drink.id %}" class="user-select" method="POST">{% csrf_token %}
        <div class="input-append">
          <input class="span8" name="username" type="text" placeholder="username" />
          <button class="btn" type="submit" name="submit_reassign">
            <i class="icon-user"></i> {% if drink.user %}Reassign{% else %}Assign{% endif %}
          </button>
          <a href="#cancelModal" role="button" class="btn btn-danger" data-toggle="modal">
            <i class="icon-trash icon-white"></i> Delete</a>
        </div>
      </form>
{% endif %}
</div>


{% with drink.pictures.all as pictures %}
<div class="span6">
  {% if pictures.count %}
  <img src="{{pictures.0.picture.resized.url}}">
  {% endif %}
  {% if drink.shout %}
    {% include 'kegweb/includes/drink_shout.html' %}
  {% endif %}
</div>
{% endwith %}


</div> <!-- /row-fluid -->

{% endblock content %}
