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()
|
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")
|
@bp.route("/my-tasks")
|
||||||
@login_required
|
@login_required
|
||||||
def my_tasks():
|
def my_tasks():
|
||||||
@@ -59,6 +68,11 @@ def my_tasks():
|
|||||||
for task in tasks:
|
for task in tasks:
|
||||||
sections[task.status].append(task)
|
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"])
|
completed_count = len(sections["completed"])
|
||||||
active_count = (
|
active_count = (
|
||||||
len(sections["open"])
|
len(sections["open"])
|
||||||
@@ -72,6 +86,7 @@ def my_tasks():
|
|||||||
return render_template(
|
return render_template(
|
||||||
"tasks/my_tasks.html",
|
"tasks/my_tasks.html",
|
||||||
sections=sections,
|
sections=sections,
|
||||||
|
soon_tasks=soon_tasks,
|
||||||
completion_ratio=completion_ratio,
|
completion_ratio=completion_ratio,
|
||||||
today=today_local(),
|
today=today_local(),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -46,41 +46,13 @@
|
|||||||
<section class="stack">
|
<section class="stack">
|
||||||
<div class="section-heading">
|
<div class="section-heading">
|
||||||
<h2>Bald fällig</h2>
|
<h2>Bald fällig</h2>
|
||||||
<span class="section-heading__count">{{ sections.due_today|length }}</span>
|
<span class="section-heading__count">{{ soon_tasks|length }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="task-grid">
|
<div class="task-grid">
|
||||||
{% for task in sections.due_today %}
|
{% for task in soon_tasks %}
|
||||||
{{ task_card(task, current_user) }}
|
{{ task_card(task, current_user) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="empty-state">Heute ist gerade nichts mehr auf Kante.</div>
|
<div class="empty-state">Gerade ist nichts bald fällig. Sehr stark.</div>
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="stack">
|
|
||||||
<div class="section-heading">
|
|
||||||
<h2>Morgen fällig</h2>
|
|
||||||
<span class="section-heading__count">{{ sections.due_tomorrow|length }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="task-grid">
|
|
||||||
{% for task in sections.due_tomorrow %}
|
|
||||||
{{ task_card(task, current_user) }}
|
|
||||||
{% else %}
|
|
||||||
<div class="empty-state">Für morgen sieht es gerade entspannt aus.</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="stack">
|
|
||||||
<div class="section-heading">
|
|
||||||
<h2>Übermorgen fällig</h2>
|
|
||||||
<span class="section-heading__count">{{ sections.due_day_after_tomorrow|length }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="task-grid">
|
|
||||||
{% for task in sections.due_day_after_tomorrow %}
|
|
||||||
{{ task_card(task, current_user) }}
|
|
||||||
{% else %}
|
|
||||||
<div class="empty-state">Auch übermorgen ist noch nichts Drängendes drin.</div>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user