From 98ed3ff3ce4812151e04ab49b6176435f2564f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20Mint=C4=9Bl?= Date: Wed, 9 Oct 2024 23:47:52 +0200 Subject: [PATCH] Pregenerate link url --- api/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/views.py b/api/views.py index 52c1ddd1..1056f4b4 100644 --- a/api/views.py +++ b/api/views.py @@ -1,11 +1,10 @@ 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 -from django.urls import reverse from common.models import ( Submit, Class, @@ -97,6 +96,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})