fix: regroup soon tasks in my tasks view
This commit is contained in:
@@ -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(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user