Show only open (TODO and IN_PROGRESS) tasks by default

This commit is contained in:
Luca 2022-06-19 14:58:18 +02:00
parent e6ea071762
commit 37ccc00eaf
3 changed files with 27 additions and 0 deletions

View File

@ -13,6 +13,20 @@
</div>
<div class="level-right">
<div class="level-item">
{% if request.resolver_match.url_name == "all_tasks" %}
{% translate "All" %}
{% else %}
<a href="{% url 'all_tasks' %}">{% translate "All" %}</a>
{% endif %}
</div>
<div class="level-item">
{% if request.resolver_match.url_name == "tasks" %}
{% translate "Open" %}
{% else %}
<a href="{% url 'tasks' %}">{% translate "Open" %}</a>
{% endif %}
</div>
<div class="level-item">
<a class="button is-success" href="{% url 'create_task' %}">{% translate "New task" %}</a>
</div>
</div>

View File

@ -8,6 +8,7 @@ urlpatterns = [
path("", views.index, name="index"),
path("tags/<slug:slug>", views.tag, name="tag"),
path("tasks", views.tasks, name="tasks"),
path("tasks/all", views.all_tasks, name="all_tasks"),
path("tasks/new", views.create_task, name="create_task"),
path("tasks/<int:task_id>", views.task, name="task"),
path("tasks/<int:task_id>/edit", views.edit_task, name="edit_task"),

View File

@ -57,6 +57,18 @@ def tag(request, slug):
@login_required
def tasks(request):
tasks = Task.objects.filter(
state__in=(Task.State.TODO, Task.State.IN_PROGRESS)
).order_by("-updated_at")
pagination = paginate_tasks(
tasks, request.GET.get("per_page"), request.GET.get("page")
)
return render(request, "core/tasks.html", pagination)
@login_required
def all_tasks(request):
tasks = Task.objects.order_by("-updated_at")
pagination = paginate_tasks(
tasks, request.GET.get("per_page"), request.GET.get("page")