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)