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

{% block content %}

<div class="page-header">
  <h1>Farm: {{ farm.name }} ({{ farm.source }})</h1>
</div>

<ol class="breadcrumb">
  <li><a href="{% url 'service-list' %}">Home</a></li>
  <li><a href="{% url 'farm-list' %}">Farms</a></li>
  <li class="active"><a href="{% url 'farm-detail' farm.id %}">{{ farm.name }}</a></li>
</ol>

<div class="row">

<div class="col-md-6">
  <div class="panel panel-default">
    <div class="panel-heading">Hosts from {{ farm.name }} ({{ farm.source }})</div>
    <table class="table">
      <tr>
        <th>Name</th>
      {% if farm.editable %}
        <th>&nbsp;</th>
      {% endif %}
      </tr>
    {% for host in farm.host_set.all %}
      <tr>
        <td><a href="{% url 'host-detail' host.name %}">{{ host.name }}</a></td>
        {% if farm.editable %}
        <td>
          <form method="post" action="{% url 'host-delete' host.id %}" onsubmit="return confirm('Really delete this host?');">
            {% csrf_token %}
          <button name="delete" type="submit" class="btn btn-danger">Delete</button>
          </form>
        </td>
        {% endif %}
      </tr>
    {% endfor %}
    </table>

    <div class="panel-footer">
  {% if farm.editable %}
      <a href="{% url 'hosts-add' farm.id %}" class="btn btn-primary">{% trans "Register Hosts" %}</a>
  {% 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">Delete Farm</button>
    </form>
    </div>
  </div>
</div>

<div class="col-md-6">
  <div class="panel panel-default">
    <div class="panel-heading">Projects using {{ farm.name }} ({{ farm.source }})</div>
    <table class="table">
{% for project in farm.project_set.all %}
      <tr>
        <td><a href="{% url 'project-detail' project.id %}">{{ project.name }}</a></td>
      </tr>
{% endfor %}
    </table>
  </div>
</div>

</div>

{% endblock %}
