Browse Source

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

pull/20/head
Jonas Havelka 2 years ago
parent
commit
d9756d5f60
  1. 10
      odevzdavatko/static/odevzdavatko/dynamic_formsets_for_detail.js
  2. 4
      odevzdavatko/views.py

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

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

Loading…
Cancel
Save