{% extends 'todo/base.html' %}

{% block title %}Todo list{% endblock %}

{% block sidebar %}
  {% if user %}
    <div>
      <h3>Manage tasks</h3>
      <p>
        <a href="/{{ app }}/new" class="button">Create task</a>
      </p>
      <p class="last">
        <b>Show:</b>
        <a href="/{{ app }}">All</a>,
        <a href="/{{ app }}/notfinished">Not finished</a>,
        <a href="/{{ app }}/finished">Finished</a>
      </p>
    </div>
  {% else %}
    <div>
      <p>For create, edit or delete todo's you need login.</p>
      <p class="last">
        This is list of your own tasks. Login to site and create your own records.
        After this logout and see this message and empty list. If you have
        different accounts - login by each of this accounts and see that all records
        available only for your account.
      </p>
    </div>
  {% endif %}
{% endblock %}

{% block content %}
  <h1>{{ user|default:"guest"|capfirst }} todo list</h1>

  <div class="todo">
  {% for todo in todos %}
    <div class="task {% if forloop.last %}last{% endif %}">
      <a href="/{{ app }}/todo_{{ todo.key.id }}" class="header">{{ todo.title }}</a>
      {{ todo.description|default:"" }}
      {% if todo.manager or user.is_admin %}
      <p class="actions last">
        <a href="/{{ app }}/edit_{{ todo.key.id }}">Edit</a>
        <a href="/{{ app }}/delete_{{ todo.key.id }}">Delete</a>
      </p>
      {% endif %}
    </div>
  {% endfor %}
  </div>
{% endblock %}