diff --git a/app/routes/tasks.py b/app/routes/tasks.py index f2c1cf2..857ca2c 100644 --- a/app/routes/tasks.py +++ b/app/routes/tasks.py @@ -33,6 +33,15 @@ def _secondary_user_choices() -> list[tuple[int, str]]: return [(0, "Keine zweite Person")] + _user_choices() +def _my_tasks_soon_priority(task: TaskInstance) -> int: + order = { + "due_tomorrow": 0, + "due_day_after_tomorrow": 1, + "due_today": 2, + } + return order.get(task.status, 99) + + @bp.route("/my-tasks") @login_required def my_tasks(): @@ -59,6 +68,11 @@ def my_tasks(): for task in tasks: sections[task.status].append(task) + soon_tasks = sorted( + sections["due_tomorrow"] + sections["due_day_after_tomorrow"] + sections["due_today"], + key=lambda task: (_my_tasks_soon_priority(task), task.due_date, task.title.lower()), + ) + completed_count = len(sections["completed"]) active_count = ( len(sections["open"]) @@ -72,6 +86,7 @@ def my_tasks(): return render_template( "tasks/my_tasks.html", sections=sections, + soon_tasks=soon_tasks, completion_ratio=completion_ratio, today=today_local(), ) diff --git a/app/templates/tasks/my_tasks.html b/app/templates/tasks/my_tasks.html index 2af51ab..bc2a619 100644 --- a/app/templates/tasks/my_tasks.html +++ b/app/templates/tasks/my_tasks.html @@ -46,41 +46,13 @@

Bald fällig

- {{ sections.due_today|length }} + {{ soon_tasks|length }}
- {% for task in sections.due_today %} + {% for task in soon_tasks %} {{ task_card(task, current_user) }} {% else %} -
Heute ist gerade nichts mehr auf Kante.
- {% endfor %} -
-
- -
-
-

Morgen fällig

- {{ sections.due_tomorrow|length }} -
-
- {% for task in sections.due_tomorrow %} - {{ task_card(task, current_user) }} - {% else %} -
Für morgen sieht es gerade entspannt aus.
- {% endfor %} -
-
- -
-
-

Übermorgen fällig

- {{ sections.due_day_after_tomorrow|length }} -
-
- {% for task in sections.due_day_after_tomorrow %} - {{ task_card(task, current_user) }} - {% else %} -
Auch übermorgen ist noch nichts Drängendes drin.
+
Gerade ist nichts bald fällig. Sehr stark.
{% endfor %}