{% extends "coprs/detail/settings.html" %}
{% from "coprs/detail/_permissions_table.html" import permissions_table with context%}

{% set selected_monitor_tab = "permissions" %}
{%block settings_breadcrumb %}Permissions{% endblock %}


{% block tab_content %}

<h2> Project Permissions </h2>
<p>This view shows permissions of other users to build or manage this project.</p>

{% if (g.user and g.user != copr.user) or permissions %}
  {# the table is displayed only if there are some permissions or a non-owner is viewing the page (then display at least his applier form #}

  {% if g.user.id != copr.user_id %}
    <div class="clearfix">
      <h3>Request Permissions</h3>
      {{ permissions_table(permissions, current_user_permissions, copr, permissions_applier_form, None) }}
    </div>
  {% endif %}

  {% if permissions_form %}
    <div class="clearfix">
      <h3>Manage Permissions</h3>
      {{ permissions_table(permissions, current_user_permissions, copr, None, permissions_form) }}
    </div>
  {% endif %}

{% else %}
  <h3>No permissions yet</h3>
  <p>You could not grant permission directly. First the other user have to navigate to this project and open this
     tab. Then he can apply for permission. You will then receive email. Once you return to this page you can either
     approve or reject this request.
  </p>
{% endif %}

{% endblock %}
