From 6216866eaf50042c0e9510365c1eb6fb92c1c8a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20Mint=C4=9Bl?= Date: Wed, 9 Oct 2024 23:52:32 +0200 Subject: [PATCH 1/2] Changed default page size to 25 + added link to task --- frontend/src/Teacher/AllTasks.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/Teacher/AllTasks.vue b/frontend/src/Teacher/AllTasks.vue index 19dd1f20..d6273605 100644 --- a/frontend/src/Teacher/AllTasks.vue +++ b/frontend/src/Teacher/AllTasks.vue @@ -18,6 +18,7 @@ type Task = { title: string; subject: string; date: Date; + link: string; }; type RawTask = Omit & { @@ -109,9 +110,10 @@ const columns = [ }, { title: 'Title', - data: 'title', + data: (row: Task) => row, orderable: true, - searchable: true + searchable: true, + render: (data: Task) => `${data.title}` }, { title: 'Subject', @@ -174,7 +176,8 @@ const options = { callback({ data: items, recordsTotal: count, recordsFiltered: count }); // https://datatables.net/manual/server-side#Returned-data }, - orderMulti: false + orderMulti: false, + pageLength: 25 } satisfies Config; //save ref to data table and if it changes save datatable instance to table variable From 909d02813239910a65ae8acaad18dfb28eaf1e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20Mint=C4=9Bl?= Date: Wed, 9 Oct 2024 23:52:39 +0200 Subject: [PATCH 2/2] Pregenerate link url --- api/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/views.py b/api/views.py index 52c1ddd1..100dae70 100644 --- a/api/views.py +++ b/api/views.py @@ -1,7 +1,7 @@ from collections import defaultdict import django.http -from django.shortcuts import get_object_or_404 +from django.shortcuts import get_object_or_404, resolve_url from django.http import HttpRequest, HttpResponseBadRequest from django.views.decorators.http import require_POST from django.contrib.auth.models import User @@ -97,6 +97,7 @@ def tasks_list_all(request: HttpRequest, subject_abbr: str | None = None): "path": task.code, "subject": task.subject.abbr, "date": task.created_at, + "link": resolve_url("teacher_task", task_id=task.pk), } ) return JsonResponse({"tasks": result, "count": allCount})