{% extends "base.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% load recapture %}
{% load sekizai_tags i18n wiki_tags static %}


{% block head-open-graph %}
  <meta property="og:title" content="New request made" />
  <meta property="og:type" content="website" />
  <meta property="og:url" content="{{ request.build_absolute_uri }}" />
  <meta property="og:image" content="https://maidstone-hackspace.org.uk/static/images/android-chrome-192x192.png" />
{% endblock head-open-graph %}

{% block content %}
  <h2>Requests</h2>

  <div class="row">
    <div class="col">
  Make a request for equipment you would like to see in the space, request training on equipment or ask a member to run a workshop or talk on something.
    </div>
  </div>


  {% if form %}
    <form method="POST" action="{% url 'requests_form' %}" class="ui form">
      {% csrf_token %}
      {% include "partials/form.html" %}
    </form>
  {% else %}
  <div class="row">
    <div class="col mt-4">
      <ul class="nav navbar-nav float-right">
        <li class="pull-xs-right" >
          <a href="{% url 'requests_form' %}" class="btn btn-primary btn-lg active pull-xs-right" role="button" aria-pressed="true">Request Equipment or Talk</a>
        </li>
      </ul>
    </div>
  </div>
  <h3>Active Requests</h3>
    <table class="table table-striped">
      <thead>
        <tr>
          <th>#</th>
          <th>Type</th>
          <th>Date</th>
          <th>Detail</th>
        </tr>
      </thead>
      {% for request in requests %}
      <tr>
        <th scope="row"> {{ forloop.counter }} </th>
        <td>
          {{ request.request_type_string }}
        </td>
        <td>
          {{ request.created_date }}
        </td>
        <td>
          <a href="{% url 'requests_detail' request.id %}">{{ request.title }}</a>
        </td>
        <td>
          <button data-toggle="collapse" data-target="#expand{{forloop.counter}}" class="fa fa-expand ml-auto" ></button>
        </td>
      </tr>
      <tr>
        <td id="expand{{forloop.counter}}" colspan="5" class="collapse span-table">{{ request.description }}</td>
      </tr>

      {% endfor %}
    </table>


    <h3>Completed Requests</h3>
    <table class="table table-striped">
      <thead>
        <tr>
          <th>#</th>
          <th>Type</th>
          <th>Date</th>
          <th>Detail</th>
        </tr>
      </thead>
      {% for request in requests_history %}
      <tr>
        <th scope="row"> {{ forloop.counter }} </th>
        <td>
          {{ request.request_type_string }}
        </td>
        <td>
          {{ request.created_date }}
        </td>
        <td>
          {{ request.title }}
        </td>
        <td>
          <button data-toggle="collapse" data-target="#expand{{forloop.counter}}" class="fa fa-expand ml-auto" ></button>
        </td>
      </tr>
      <tr>
        <td id="expand{{forloop.counter}}" colspan="5" class="collapse span-table">{{ request.description }}</td>
      </tr>

      {% endfor %}
    </table>


  {% endif %}
{% endblock content %}

