From d2e199e509490b95905ecc21759b56644ceca0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 20 Jan 2025 23:40:06 +0100 Subject: [PATCH] =?UTF-8?q?Dynamick=C3=BD=20update=20stavu=20opravy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- korektury/api/urls.py | 1 + korektury/api/views.py | 14 ++++++++++++ .../korektury/korekturovatko/htmlstrana.html | 22 +++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/korektury/api/urls.py b/korektury/api/urls.py index 23ac8559..99a1d13f 100644 --- a/korektury/api/urls.py +++ b/korektury/api/urls.py @@ -4,4 +4,5 @@ from . import views urlpatterns = [ path('korektury/api//stav', org_required(views.korektury_stav_view), name='korektury_api_pdf_stav'), + path('korektury/api/oprava/stav', org_required(views.oprava_stav_view), name='korektury_api_oprava_stav'), ] diff --git a/korektury/api/views.py b/korektury/api/views.py index 358a3502..86149803 100644 --- a/korektury/api/views.py +++ b/korektury/api/views.py @@ -18,3 +18,17 @@ def korektury_stav_view(request, pdf_id: int, **kwargs): pdf.status = status pdf.save() return JsonResponse({'status': pdf.status}) + + +def oprava_stav_view(request, **kwargs): + q = request.POST + op_id_str = q.get('id') + assert op_id_str is not None + op_id = int(op_id_str) + op = get_object_or_404(Oprava, id=op_id) + status = q.get('action') + if status is not None: + assert status in Oprava.STATUS.values + op.status = status + op.save() + return JsonResponse({'status': op.status}) diff --git a/korektury/templates/korektury/korekturovatko/htmlstrana.html b/korektury/templates/korektury/korekturovatko/htmlstrana.html index acac7ee9..9f4d2274 100644 --- a/korektury/templates/korektury/korekturovatko/htmlstrana.html +++ b/korektury/templates/korektury/korekturovatko/htmlstrana.html @@ -42,3 +42,25 @@
+ + + +