{% extends "base.html" %}
{% load i18n %}
{% block content %}

<div class="page-header">
  <h1>Farms</h1>
</div>

<ol class="breadcrumb">
  <li><a href="{% url 'service-list' %}">Home</a></li>
  <li class="active">All Farms</li>
</ol>

<div class="panel panel-default">
    <table class="table table-bordered table-condensed">
      <thead>
        <tr>
          <th>Farm</th>
          <th>Source</th>
          <th>Hosts</th>
          <th>Project</th>
          <th>&nbsp;</th>
        </tr>
      </thead>
{% for farm in farm_list %}
      <tr>
        <td><a href="{% url 'farm-detail' farm.id %}">{{ farm.name }}</a></td>
        <td>
          {% if farm.driver.remote %}
            <span class="glyphicon glyphicon-cloud-download" aria-hidden="true"></span>
          {% endif %}
          {{ farm.source }}
        </td>
        <td>
          <ul>
{% for host in farm.host_set.all %}
            <li><a href="{% url 'host-detail' host.name %}">{{ host.name }}</a></li>
{% endfor %}
          </ul>
        </td>
        <td>
          <ul>
          {% for project in farm.project_set.all %}
            <li><a href="{% url 'project-detail' project.id %}">{{ project.name }}</a></li>
          {% endfor %}
          </ul>
        </td>
        <td>
          {% if farm.driver.remote %}
          <form method="post" action="{% url 'farm-convert' farm.id %}" onsubmit="return confirm('Convert this farm to local?')" style="display: inline">
            {% csrf_token %}
            <button class="btn btn-warning">{% trans "Convert to Local Farm" %}</button>
          </form>
          {% endif %}
          <form method="post" action="{% url 'farm-delete' farm.id %}" onsubmit="return confirm('Delete this farm?')" style="display: inline">
            {% csrf_token %}
            <button class="btn btn-danger">{% trans "Delete" %}</button>
          </form>
        </td>
      </tr>
{% endfor %}
    </table>

</div>

{% endblock %}
