{% extends "network/base.html" %}
{% load render_table from django_tables2 %}
{% load i18n %}
{% load l10n %}
{% load staticfiles %}
{% load crispy_forms_tags %}

{% block content %}
<div class="page-heading">
  <h1>{{ form.hostname.value }} <small>details of host</small></h1>
</div>


<div class="row">
  <div class="span8">
    {% crispy form %}
  </div>
  <div class="span4">
    <h3>Rules</h3>
    {% render_table rule_list %}
    
    <h3>Groups</h3>
    {% for group in group_rule_list %}
        <div>
            <h4 id="{{ group.pk }}_group_pk">{{ group.name }} 
                <a href="{% url network.remove_host_group pk=host_pk group_pk=group.pk %}?from={{ request.path }}">
                    <i class="icon-remove" style="vertical-align: middle;"></i></a>
            <a href="{% url network.group group.pk %}">
                <i class="icon-pencil" style="vertical-align: middle;"></i></a>
            </h4>
            {% render_table group.table %}
        </div>
    {% endfor %}
    
    <h3>Add host group</h3>
    {% if not_used_groups|length == 0 %}
      No more groups to add!
    {% else %}
      <form action="{% url network.add_host_group pk=host_pk %}" method="POST">
        {% csrf_token %}
        <div class="input-append">
          <select name="group" id="add_group">
            {% for rest in not_used_groups %}
              <option value="{{ rest.pk }}">{{ rest }}</option>
            {% endfor %}
          </select>
          <input type="submit" value="Add group" class="btn"></input>
        </div><!-- input append -->
      </form>
    {% endif %}
  </div><!-- span4 -->
</div><!-- row -->
{% endblock %}
