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

{% block title %}{{ list_title }} Todo Lists{% endblock %}

{% block content %}
  <h1>Todo Lists</h1>

  <p>{{ task_count }} tasks in {{ list_count }} list{{ list_count|pluralize }}</p>

  {% regroup lists by group as section_list %}
  {% for group in section_list %}
    <h3>Group: {{ group.grouper }}</h3>
    <ul class="list-group mb-4">
      {% for task in group.list %}
      <li class="list-group-item d-flex justify-content-between align-items-center">
        <a href="{% url 'todo:list_detail' task.id task.slug %}">{{ task.name }}</a>
        <span class="badge badge-primary badge-pill">{{ task.task_set.count }}</span>
      </li>
      {% endfor %}
    </ul>
  {% endfor %}

  <div class="mt-3">
    
    {% if user.is_staff %}
      <a href="{% url 'todo:add_list' %}" class="btn btn-primary">Create new todo list</a>
    {% else %}
      <a href="" class="btn btn-primary disabled">If you were staff, you could create a new list</a>
    {% endif %}
      
  </div>

{% endblock %}