{% extends 'safety/safety_base.html' %}
{% load custom_tags_and_filters %}
{% block title %}Safety issues{% endblock %}
{% block safety_title %}Existing safety issues{% endblock %}
{% block tab_content %}
    <p>This page lists ongoing safety issues.</p>
    <p>Use the buttons on the right side to report a safety concern or view past safety issues.</p>
    <div class="text-right" style="margin-bottom: 15px">
        {% button type="delete" url="create_safety_issue" value="Report safety concern" icon="glyphicon-plus-sign" %}
        {% button type="info" url="resolved_safety_issues" value="Past safety issues" icon="glyphicon-list" %}
    </div>
    {% if tickets %}
        {% for ticket in tickets %}
            {% if user.is_staff %}
                <a href="{% url 'update_safety_issue' ticket.id %}" style="text-decoration: none">
                {% endif %}
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="form-group">
                            <h4>
                                {% if ticket.id in notifications %}<span class="badge active" style="vertical-align:middle;">New</span>{% endif %}
                                Concern
                            </h4>
                            {{ ticket.concern|linebreaksbr }}
                        </div>
                        <div class="form-group">
                            {% if not ticket.visible %}
                                <span class="glyphicon glyphicon-eye-close"></span> This issue is hidden from users
                                <br>
                            {% endif %}
                            {% if ticket.location %}
                                Location: {{ ticket.location }}
                                <br>
                            {% endif %}
                            {% if ticket.reporter %}
                                Reported on {{ ticket.creation_time }}
                                {% if user.is_staff %}by {{ ticket.reporter }}{% endif %}
                                <br>
                            {% else %}
                                Reported anonymously on {{ ticket.creation_time }}
                                <br>
                            {% endif %}
                        </div>
                        {% if ticket.progress %}
                            <div class="form-group">
                                <h4>Progress</h4>
                                {{ ticket.progress|linebreaksbr }}
                            </div>
                        {% endif %}
                    </div>
                </div>
                {% if user.is_staff %}</a>{% endif %}
        {% endfor %}
    {% else %}
        <p>
            <i>There are no ongoing safety issues.</i>
        </p>
    {% endif %}
{% endblock %}
