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

{% block browser_title %}{% blocktrans %}Home{% endblocktrans %}{% endblock %}
{% block no_page_title %}{% endblock %}

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

{% block content %}
  {% has_perm "core.edit_dashboard_rule" user as can_edit_dashboard %}
  {% if can_edit_dashboard and show_edit_dashboard_button %}
    <div class="row no-margin">
      <a class="btn-flat waves-effect waves-light right" href="{% url "edit_dashboard" %}">
        <i class="material-icons left iconify" data-icon="mdi:pencil-outline"></i>
        {% trans "Edit dashboard" %}
      </a>
    </div>
  {% endif %}

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

  <div class="row" id="live_load">
    {% for widget in widgets %}
      <div class="col s{{ widget.size_s }} m{{ widget.size_m }} l{{ widget.size_l }} xl{{ widget.size_xl }}">
        {% include_widget widget %}
      </div>
    {% endfor %}
  </div>

  {% if default_dashboard and widgets and can_edit_dashboard %}
    <div class="grey-text right">
      {% blocktrans %}
        You didn't customise your dashboard so that you see the system default. Please click on "Edit dashboard" to
        customise your personal dashboard.
      {% endblocktrans %}
    </div>
  {% endif %}

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

        {% 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 iconify" data-icon="mdi:clock-outline"></i> {{ activity.created }}
                </p>
                <p>
                  {{ activity.description }}
                </p>
              </li>
            {% endfor %}
          </ul>
        {% else %}
          <p>{% blocktrans %}No activities available yet.{% endblocktrans %}</p>
        {% endif %}
      </div>
    </div>
  {% endif %}

  {% if user.person.preferences.general__automatically_update_dashboard and SITE_PREFERENCES.general__automatically_update_dashboard_site %}
    <script type="text/javascript" src="{% static "js/include_ajax_live.js" %}"></script>
  {% endif %}
{% endblock %}
