add: ukládání různých bodů

This commit is contained in:
Jonas Havelka 2023-01-02 23:44:36 +01:00
parent 39da362586
commit d9756d5f60
2 changed files with 14 additions and 0 deletions

View file

@ -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);
})
});

View file

@ -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)