from django.http import HttpResponseForbidden, JsonResponse from django.shortcuts import get_object_or_404 from django.views.decorators.csrf import csrf_exempt from rest_framework import serializers from korektury.utils import send_email_notification_komentar from korektury.models import Oprava, KorekturovanePDF, Komentar from personalni.models import Organizator, Osoba def korektury_stav_view(request, pdf_id: int, **kwargs): q = request.POST pdf = get_object_or_404(KorekturovanePDF, id=pdf_id) status = q.get('state') if status is not None: assert status in KorekturovanePDF.STATUS.values pdf.status = status pdf.save() return JsonResponse({'status': pdf.status})