{% extends 'layouts/default.html' %}
{% from 'forms/macros.html' import render_field %}
{% block title %}Add RTBH rule{% endblock %}
{% block content %}
  <h2>{{ title or 'New'}} RTBH rule</h2>
  <form action="{{ action_url }}" method="POST">
  {{ form.hidden_tag() if form.hidden_tag }}
  <div class="row">
    <div class="col-sm-8">
      <div class="row">
        <div class="col-sm-8">
          {{ render_field(form.ipv4) }}
        </div>
        <div class="col-sm-4">
            {{ render_field(form.ipv4_mask) }}
        </div>
      </div>
      <div class="row">
        <div class="col-sm-8">
          {{ render_field(form.ipv6) }}
        </div>
        <div class="col-sm-4">
            {{ render_field(form.ipv6_mask) }}
        </div>
      </div>
    </div>
    <div class="col-sm-4">
      <div class="row">
        {{ render_field(form.community) }}
      </div>
      <div class="row">
        <h6>Following communities can be whitelisted:</h6>
        <ul class="list-group">
          {% for com in whitelistable %}
            <li class="list-group-item">
              {{ com }}
            </li>
          {% endfor %}
        </ul>
    </div>  
  </div>  

  <div class="row">
    <div class="col-sm-6">
      <div class="form-group">
        <label for="inputExpiration" class="control-label">Expiration date</label>
        <div class='input-group date' id='dateTimeExpires'>
                      {{ form.expires(class_='form-control') }}
                      <span class="input-group-addon">
                          <span class="glyphicon glyphicon-calendar"></span>
                      </span>
        </div>

        {% if form.expires.errors %}
            {% for e in form.expires.errors %}
                <p class="help-block">{{ e }}</p>
            {% endfor %}
        {% endif %}
      </div>            
    </div>
  </div>

  <div class="row">
    <div class="col-sm-12">
         {{ render_field(form.comment) }}
    </div>
  </div>

  <div class="row">
    <div class="col-sm-10">
      <button type="submit" class="btn btn-primary">Save</button>
    </div>
  </div>
  </form>
{% endblock %}