{% extends "base.html" %}
{% load i18n static inkscape %}

{% block "css" %}{{ block.super }}
  <link rel="stylesheet" type="text/css" href="{% static "css/alert.css" %}"/>
{% endblock %}
{% block "js" %}{{ block.super }}
  <script type="text/javascript" src="{% static "js/alert.js" %}"></script>
{% endblock %}

{% block content %}
  <h1>{{ title }}
      <div class="runner">
        <a class="button" href="{% url "alert.settings" %}" title="{% trans "Manage notification settings" %}">&#9881;</a>
      </div>
    {% if object_list.count > 0 %}
      <form class="runner" data-confirm="{% trans "Delete all notifications" %}" action="{% url "alert.delete" %}">
        <button class="button" id="{{ object.pk }}" title="{% trans "Are you sure that you want to delete all your notifications?" %}">X</button>
      </form>
    {% endif %}
    {% if object_list.new.count > 0 %}
      <form class="runner" action="{% url "alert.view" %}">
        <button class="button" id="{{ object.pk }}" title="{% trans "Mark all as read" %}">&#10004;</button>
      </form>
    {% endif %}
  </h1>

  <h2 id="empty" style="display: none;">{% trans "No notifications to view" %}</h2>

<div id="items">
  {% for object in object_list %}
    {% with object.data as data %}

<div class="comment" id="alert_{{ object.pk }}">
  <div class="details">
    <div class="title">
      {% if data.instance_deleted %}
        <img src="{% static "images/deleted.png" %}" alt="{% trans "Deleted" %}"/>
        <del>{{ data.instance_deleted }}</del>
      {% elif not object.viewed %}
        <img src="{% static "images/email.png" %}" alt="{% trans "New" %}" title="{% trans "New Notification" %}"/>
        {{ object.subject }}
      {% else %}
        {{ object.subject }}
      {% endif %}
    </div>
    <div class="index">
      <form class="runner read" {% if object.viewed %}style="display: none;"{% endif %} action="{% url "alert.view" object.pk %}">
        <button id="{{ object.pk }}" title="{% trans "Mark as Read" %}">&#10004;</button>
      </form>
      <form class="runner" action="{% url "alert.delete" object.pk %}">
        <button id="{{ object.pk }}" title="{% trans "Delete Alert" %}">X</button>
      </form>
    </div>
    <div class="index">{{ object.created|timetag }}</div>
  </div>
  {% if not data.instance_deleted %}
    {{ object.body }}
  {% else %}
    <div class="body">
      <div class="text"><p>{% trans "This notification was for an object that no longer exists. It has been deleted." %}</p></div>
    </div>
  {% endif %}
</div>

    {% endwith %}
  {% endfor %}
</div>

{% endblock %}

