Commit be367594 authored by Élie Bouttier's avatar Élie Bouttier
Browse files

nombre de tâches assignés à l’utilisateur courant

parent 39a31f0f
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -3,13 +3,18 @@
{% block content %}
  <h1>Liste des tâches</h1>

  <p>{{ task_count }} tâche{{ task_count|pluralize }} dans {{ list_count }} liste{{ list_count|pluralize }}</p>
  <p>{{ task_count }} tâche{{ task_count|pluralize }} en cours dans {{ list_count }} liste{{ list_count|pluralize }}</p>

  <ul class="list-group mb-4">
    {% for list in lists %}
    <li class="list-group-item d-flex justify-content-between align-items-center">
      <a href="{% url 'todo:show-tasklist' list.slug %}">{{ list.name }}</a>
      <span class="text-right">
        {% if list.own_uncompleted_task_count %}
        <span class="badge badge-danger badge-pill">{{ list.own_uncompleted_task_count }}</span>
        {% endif %}
        <span class="badge badge-primary badge-pill">{{ list.uncompleted_task_set.count }}</span>
      </span>
    </li>
    {% endfor %}
  </ul>
+2 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from django.utils import timezone
from django.db.models import Count, Q

from .models import TaskList, Task
from .forms import TaskForm, CommentForm
@@ -19,6 +20,7 @@ def tasklist_list(request):
    if not request.user.is_superuser:
        lists = lists.filter(group__in=request.user.groups.all())
    lists = lists.order_by('name')
    lists = lists.annotate(own_uncompleted_task_count=Count('task', filter=Q(task__completed_date__isnull=True, task__assigned_to=request.user)))
    return render(request, 'todo/tasklist_list.html', {
        'lists': lists,
        'task_count': Task.objects.filter(completed_date__isnull=True, task_list__in=lists).count(),