{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}

{% block form_id %}upload_rack_form{% endblock %}
{% block form_action %}{% url 'horizon:infrastructure:resource_management:racks:upload' %}{% endblock %}
{% block form_attrs %}enctype="multipart/form-data"{% endblock %}

{% block modal_id %}upload_rack_modal{% endblock %}
{% block modal-header %}{% trans "Upload Rack" %}{% endblock %}

{% block modal-body %}
  <div>
    <fieldset>
      <span class="control-group clearfix error">
        {% if form.csv_file.errors %}
          <div class="error help-inline">{{ form.csv_file.errors }}</div>
        {% endif %}
      </span>
      {{ form.csv_file }}
      <input class="btn btn-primary pull-right always-enabled" type="submit" name=upload value="{% trans "Upload File" %}" />
      <div class="help-block">
        CSV file format:<br>rack name,resource class name,subnet,region,list of mac addresses separated by space
      </div>
      {{ form.uploaded_data }}
    </fieldset>
  </div>
  <div class="csv_rack_table">
    {% trans "Uploaded racks, which you are going to add to the system:" %}
    {{ racks_table.render }}
  </div>
{% endblock %}

{% block modal-footer %}
<input class="btn btn-primary pull-right always-enabled" type="submit" name=add_racks value="{% trans "Add Racks" %}" {% if not form.uploaded_data.value %}disabled{% endif %}/>
  <a href="{% url 'horizon:infrastructure:resource_management:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}
