{% extends g.theme.master %}

{% block title %}{{neighborhood.name}} / Award Administration{% endblock %}

{% block header %}Award Administration for {{neighborhood.name}}{% endblock %}

{% block nav_menu %}
{% include 'allura:templates/jinja_master/neigh_nav_menu.html' %}
{% endblock %}

{% block top_nav %}
{% include 'allura:templates/jinja_master/neigh_top_nav.html' %}
{% endblock %}

{% block content %}
          {% if awards_count > 0 %}
          <p>
          <h3>Current Awards</h3>
            <div id="award_list">
              <table>
                <thead>
                  <tr>
                    <th>Icon</th>
                    <th>Abbreviation</th>
                    <th>Description</th>
                    <th>Delete?</th>
                  </tr>
                </thead>
                <tbody>
                  {% for award in awards %}
                    <tr>
                      <td>
                        {% if award.icon %}
                          <img class="award_icon" src="awards/{{award.url()}}/icon" alt=""/>
                        {% endif %}
                      </td>
                      <td><a href="{{award.longurl()}}">{{award.short}}</a></td>
                      <td>{{award.full}}</td>
                      <td>
                        <form action="{{award.longurl()}}/delete" method="post">
                          <input type="submit" value="Delete"/>
                        </form>
                    </tr>
                  {% endfor %}
                </tbody>
              </table>
            </div>
          </p>
          {% endif %}

          <h3>Create an Award</h3>
          <form enctype="multipart/form-data" method="POST" action="awards/create">
            <table>
              <thead>
                <tr>
                  <th>Icon</th>
                  <th>Abbreviation</th>
                  <th>Description</th>
                  <th></th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td>
                    <input type="file" id="icon" name="icon" class="text" />
                  </td>
                  <td>
                    <input name="short" type="text"/>
                  </td>
                  <td>
                    <input name="full" type="text"/>
                  </td>
                  <td>
                    <input type="submit" value="Create"/>
                  </td>
                </tr>
              </tbody>
            </table>
          </form>

          {% if awards_count > 0 %}
          <p>
            <h3>Grant an Award</h3>
            <form method="POST" action="awards/grant">
              <table>
                <thead>
                  <tr>
                    <th>Award</th>
                    <th>Recipient</th>
                    <th></th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <td>
                      <select name="grant">
                        {% for award in awards %}
                          <option value="{{award.short}}">{{award.short}}</option>
                        {% endfor %}
                      </select>
                    </td>
                    <td>
                      {{c.project_select.display(name='recipient')}}
                    </td>
                    <td>
                      <input type="submit" value="Grant"/>
                    </td>
                  </tr>
                </tbody>
              </table>
            </form>
          </p>
          {% endif %}

          {% if grants_count > 0 %}
          <p>
            <h3>Current Grants</h3>
            <div id="grant_list">
              <table>
                <thead>
                  <tr>
                    <th>Award</th>
                    <th>Recipient</th>
                    <th>Revoke?</th>
                  </tr>
                </thead>
                <tbody>
                  {% for grant in grants %}
                    <tr>
                      <td><a href="{{grant.award.longurl()}}">{{grant.award.short}}</a></td>
                      <td><a href="{{grant.granted_to_project.url()}}">{{grant.granted_to_project.shortname}}</a></td>
                      <td>
                        <form action="{{grant.longurl()}}/revoke" method="post">
                          <input type="submit" value="Revoke"/>
                        </form>
                    </tr>
                  {% endfor %}
                </tbody>
              </table>
            </div>
          </p>
          {% endif %}
{% endblock %}
