{% extends 'core/base.html' %}
{% load i18n static dashboard %}

{% block browser_title %}{% blocktrans %}Home{% endblocktrans %}{% endblock %}
{% block page_title %}{{ request.site.preferences.general__title }}{% endblock %}

{% block extra_head %}
  {{ media }}
{% endblock %}

{% block content %}
  {% if user.is_authenticated %}
    {% for notification in unread_notifications %}
      <div class="alert primary scale-transition">
        <div>
          <i class="material-icons left">info</i>

          <div class="right">
            <a class="btn-flat waves-effect" href="{% url "notification_mark_read" notification.id %}">
              <i class="material-icons center">close</i>
            </a>
          </div>

          <strong>{{ notification.title }}</strong>
          <p>{{ notification.description }}</p>
        </div>
      </div>
    {% endfor %}

    {% include "core/announcements.html" with announcements=announcements %}

    <div class="row" id="live_load">
      {% for widget in widgets %}
        <div class="col s12 m12 l6 xl4">
          {% include_widget widget %}
        </div>
      {% endfor %}
    </div>

    <div class="row">
      <div class="col s12 m6">
        <h5>{% blocktrans %}Last activities{% endblocktrans %}</h5>

        {% if activities %}
          <ul class="collection">
            {% for activity in activities %}
              <li class="collection-item">
                <span class="badge new primary-color">{{ activity.app }}</span>
                <span class="title">{{ activity.title }}</span>
                <p>
                  <i class="material-icons left">access_time</i> {{ activity.created_at }}
                </p>
                <p>
                  {{ activity.description }}
                </p>
              </li>
            {% endfor %}
          </ul>
        {% else %}
          <p>{% blocktrans %}No activities available yet.{% endblocktrans %}</p>
        {% endif %}
      </div>

      <div class="col s12 m6">
        <h5>{% blocktrans %}Recent notifications{% endblocktrans %}</h5>

        {% if notifications %}
          <ul class="collection">
            {% for notification in notifications %}
              <li class="collection-item">
                <span class="badge new primary-color">{{ notification.app }}</span>
                <span class="title">{{ notification.title }}</span>
                <p>
                  <i class="material-icons left">access_time</i> {{ notification.created_at }}
                </p>
                <p>
                  {{ notification.description }}
                </p>
                {% if notification.link %}
                  <p>
                    <a href="{{ notification.link }}">{% blocktrans %}More information →{% endblocktrans %}</a>
                  </p>
                {% endif %}
              </li>
            {% endfor %}
          </ul>
        {% else %}
          <p>{% blocktrans %}No notifications available yet.{% endblocktrans %}</p>
        {% endif %}
      </div>
    </div>
  {% endif %}

  <script type="text/javascript" src="{% static "js/include_ajax_live.js" %}"></script>
{% endblock %}
