From d9756d5f6019053ab35a826de1eb168bd6e9a53a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 2 Jan 2023 23:44:36 +0100 Subject: [PATCH] =?UTF-8?q?add:=20ukl=C3=A1d=C3=A1n=C3=AD=20r=C5=AFzn?= =?UTF-8?q?=C3=BDch=20bod=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/odevzdavatko/dynamic_formsets_for_detail.js | 10 ++++++++++ odevzdavatko/views.py | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/odevzdavatko/static/odevzdavatko/dynamic_formsets_for_detail.js b/odevzdavatko/static/odevzdavatko/dynamic_formsets_for_detail.js index a14c9f8f..1c9bf2f9 100644 --- a/odevzdavatko/static/odevzdavatko/dynamic_formsets_for_detail.js +++ b/odevzdavatko/static/odevzdavatko/dynamic_formsets_for_detail.js @@ -49,8 +49,18 @@ $(document).ready(function(){ $('#id_form-' + form_idx + '-deadline_body')[0].value = $('#id_form-' + (form_idx - 1) + '-deadline_body')[0].value } $('#id_form-TOTAL_FORMS').val(parseInt(form_idx) + 1); + + $('.bodovani').children().change(function(){ + $(this).parent().parent().children(".bodovani").children().attr("disabled", true); + $(this).attr("disabled", false); + }) }); $('.smazat_hodnoceni').click(function(){ deleteForm("form",this); }); + + $('.bodovani').children().change(function(){ + $(this).parent().parent().children(".bodovani").children().attr("disabled", true); + $(this).attr("disabled", false); + }) }); diff --git a/odevzdavatko/views.py b/odevzdavatko/views.py index d24e495a..746335fc 100644 --- a/odevzdavatko/views.py +++ b/odevzdavatko/views.py @@ -308,6 +308,10 @@ def hodnoceniReseniView(request, pk, *args, **kwargs): **form.cleaned_data, ) logger.info(f"Creating Hodnoceni: {hodnoceni}") + zmeny_bodu = [it for it in form.changed_data if it.startswith("body")] + if len(zmeny_bodu) == 1: + hodnoceni.__setattr__(zmeny_bodu[0], data_for_body[zmeny_bodu[0]]) + hodnoceni.save() hodnoceni.save() return redirect(success_url)