{% extends 'assets/base.html' %}
{% load bob %}
{% load i18n %}
{% block content %}
<div class="row-fluid">
    <h3>{% block form_title %}{{caption}}{% endblock %}</h3>
</div>
{% for error in form.non_field_errors %}
<div class="alert alert-danger">
{{ error }}
</div>
{% endfor %}
<form id="{{ form_id }}" class="form form-horizontal" method="POST"{% if edit_mode %} enctype="multipart/form-data"{% endif %} {% dependency_data asset_form %}>
  {% csrf_token %}
  <div class="row-fluid">
    <div class="span6">
    {% form_as_fieldsets form %}
    </div>
    <div class="span6">
      {% include 'assets/attachment_table.html' with attachment_parent=licence mode=mode parent_name='license' %}
      {% if licence %}
        <h6>
          <a href="{% url licence_history mode licence.id %}">
            {% trans "Licence history"%}
          </a>
        </h6>
        <h6>{% trans "Assigned users" %}</h6>
        <table class="table table-bordered">
          <thead>
              <tr>
                  <th>#</th>
                  <th>{% trans "User" %}</th>
              </tr>
          </thead>
          <tbody>
              {% for user in licence.users.all %}
              <tr>
                  <td>{{ forloop.counter }}</td>
                  <td>
                    <a href="{% url user_view user.username %}">{{ user.username }}</a>
                  </td>
              </tr>
              {% endfor %}
          </tbody>
        </table>
      {% endif %}
    </div>
  </div>
  <div class="row-fluid">
    <div class="span12">
      <div class="form-actions">
        <button name="asset" type="submit" class="btn btn-primary">Save</button>
      </div>
    </div>
  </div>
</form>
{% include 'assets/attachment_deletion.html' with attachment_parent=licence mode=mode parent_name='license'%}
{% endblock %}
