fix: regroup soon tasks in my tasks view

This commit is contained in:
2026-04-15 13:47:13 +02:00
parent ce7a371caf
commit dba87ebcf2
2 changed files with 18 additions and 31 deletions

View File

@@ -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(),
)