{% load i18n %}
{% load rules %}
{% load core_tags %}

{% has_perm 'projects.change_project_object' request.user project as can_change_project %}

{% if settings.PROJECT_VIEWS %}

<div id="project-views">

    <h2>{% trans 'Views' %}</h2>

    {% include 'projects/project_detail_views_help.html' %}

    {% if project.views.exists %}

        <table class="table">
            <thead>
                <th style="width: 20%">{% trans 'View' %}</th>
                <th style="width: 60%">{% trans 'Description' %}</th>
                <th style="width: 20%" class="text-right">
                    {% if can_change_project %}
                    <a href="{% url 'project_update_views' project.pk %}" title="{% trans 'Update project views' %}">
                        <i class="fa fa-pencil"></i>
                    </a>
                    {% endif %}
                </th>
            </thead>
            <tbody>
                {% for view in project.views.all %}
                <tr>
                    <td>
                        <a href="{% url 'project_view' project.pk view.pk %}">{{ view.title }}</a>
                    </td>
                    <td>{{ view.help|markdown }}</td>
                    <td class="text-right">
                        <a href="{% url 'project_view' project.pk view.pk %}" class="fa fa-eye"
                            title="{% trans 'Display view' %}">
                        </a>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>

    {% else %}

        {% if can_change_project %}
            <p class="project-update">
                <a href="{% url 'project_update_views' project.pk %}" title="{% trans 'Update project views' %}">
                    <i class="fa fa-pencil"></i>
                </a>
            </p>
        {% endif %}

        <p>
            {% trans 'No views are configured for this project.' %}
        </p>

    {% endif %}

</div>

{% endif %}
