From 973d3fc8bf57d607b50ec99075ae1d2b19e9a3ca Mon Sep 17 00:00:00 2001 From: Karel Balej Date: Mon, 10 Oct 2022 23:49:24 +0200 Subject: [PATCH] =?UTF-8?q?odevzdavatko:=20pol=C3=AD=C4=8Dko=20pro=20zp?= =?UTF-8?q?=C4=9Btnou=20vazbu=20=C5=99e=C5=A1iteli?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mamweb/static/css/mamweb.css | 2 +- odevzdavatko/forms.py | 5 +++-- .../templates/odevzdavatko/detail.html | 6 ++++-- .../odevzdavatko/detail_resitele.html | 3 ++- odevzdavatko/views.py | 8 ++++++-- seminar/migrations/0108_hodnoceni_feedback.py | 18 ++++++++++++++++++ seminar/models/odevzdavatko.py | 2 ++ 7 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 seminar/migrations/0108_hodnoceni_feedback.py diff --git a/mamweb/static/css/mamweb.css b/mamweb/static/css/mamweb.css index fa5de880..de02a2bd 100644 --- a/mamweb/static/css/mamweb.css +++ b/mamweb/static/css/mamweb.css @@ -417,7 +417,7 @@ input[type="file"] { display: block; } -input { +input, textarea { margin: 5px; } diff --git a/odevzdavatko/forms.py b/odevzdavatko/forms.py index 6eb2a973..856de419 100644 --- a/odevzdavatko/forms.py +++ b/odevzdavatko/forms.py @@ -88,11 +88,12 @@ ReseniSPrilohamiFormSet = inlineformset_factory(m.Reseni,m.PrilohaReseni, class JednoHodnoceniForm(forms.ModelForm): class Meta: model = m.Hodnoceni - fields = ('problem', 'body', 'deadline_body') + fields = ('problem', 'body', 'deadline_body', 'feedback',) widgets = { 'problem': autocomplete.ModelSelect2( url='autocomplete_problem_odevzdatelny', # FIXME: Dovolit i starší? - ) + ), + 'feedback': forms.Textarea(attrs={'rows': 1, 'cols': 30}), } OhodnoceniReseniFormSet = formset_factory(JednoHodnoceniForm, diff --git a/odevzdavatko/templates/odevzdavatko/detail.html b/odevzdavatko/templates/odevzdavatko/detail.html index 10f86a14..9f6d31ac 100644 --- a/odevzdavatko/templates/odevzdavatko/detail.html +++ b/odevzdavatko/templates/odevzdavatko/detail.html @@ -91,7 +91,7 @@ $(document).ready(function(){
{# Poznámka #} -

Poznámka:

+

Neveřejná poznámka:

{{ poznamka_form.poznamka }}

{# Hodnocení: #} @@ -101,13 +101,14 @@ $(document).ready(function(){ {{ form.management_form }} - + {% for subform in form %} + @@ -123,6 +124,7 @@ $(document).ready(function(){ +
ProblémBodyDeadline pro body
ProblémBodyDeadline pro bodyZpětná vazba pro řešitele
{{ subform.problem }} {{ subform.body }} {{ subform.deadline_body }}{{ subform.feedback }} Smazat
{{ form.empty_form.problem }} {{ form.empty_form.body }} {{ form.empty_form.deadline_body }}{{ form.empty_form.feedback }} Smazat
diff --git a/odevzdavatko/templates/odevzdavatko/detail_resitele.html b/odevzdavatko/templates/odevzdavatko/detail_resitele.html index 1c7622a7..fb0cb5fb 100644 --- a/odevzdavatko/templates/odevzdavatko/detail_resitele.html +++ b/odevzdavatko/templates/odevzdavatko/detail_resitele.html @@ -37,11 +37,12 @@ {# Hodnocení: #}

Hodnocení:

-{# #} +{# #} {% for h in hodnoceni %} + {# #} {% endfor %} diff --git a/odevzdavatko/views.py b/odevzdavatko/views.py index 6e0f7c47..ae466b0d 100644 --- a/odevzdavatko/views.py +++ b/odevzdavatko/views.py @@ -218,10 +218,11 @@ class DetailReseniView(DetailView): self.reseni = get_object_or_404(m.Reseni, id=self.kwargs['pk']) result = [] # Slovníky s klíči problem, body, deadline_body -- initial data pro f.OhodnoceniReseniFormSet for hodn in m.Hodnoceni.objects.filter(reseni=self.reseni): - result.append( - {"problem": hodn.problem, + result.append({ + "problem": hodn.problem, "body": hodn.body, "deadline_body": hodn.deadline_body, + "feedback": hodn.feedback, }) return result @@ -261,10 +262,12 @@ def hodnoceniReseniView(request, pk, *args, **kwargs): problem = form.cleaned_data['problem'] body = form.cleaned_data['body'] deadline_body = form.cleaned_data['deadline_body'] + feedback = form.cleaned_data['feedback'] hodnoceni = m.Hodnoceni( problem=problem, body=body, deadline_body=deadline_body, + feedback=feedback, reseni=reseni, ) logger.info(f"Creating Hodnoceni: {hodnoceni}") @@ -285,6 +288,7 @@ class ResitelReseniView(DetailView): { "problem": hodn.problem, "body": hodn.body, + "feedback": hodn.feedback, # "deadline_body": hodn.deadline_body, } ) diff --git a/seminar/migrations/0108_hodnoceni_feedback.py b/seminar/migrations/0108_hodnoceni_feedback.py new file mode 100644 index 00000000..282849d8 --- /dev/null +++ b/seminar/migrations/0108_hodnoceni_feedback.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.16 on 2022-11-14 19:30 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0107_zmrazenavysledkovka'), + ] + + operations = [ + migrations.AddField( + model_name='hodnoceni', + name='feedback', + field=models.TextField(blank=True, default='', help_text='Zpětná vazba řešiteli (plain text)', verbose_name='zpětná vazba'), + ), + ] diff --git a/seminar/models/odevzdavatko.py b/seminar/models/odevzdavatko.py index 77ed5018..9ae161c5 100644 --- a/seminar/models/odevzdavatko.py +++ b/seminar/models/odevzdavatko.py @@ -113,6 +113,8 @@ class Hodnoceni(bm.SeminarModelBase): problem = models.ForeignKey(am.Problem, verbose_name='problém', related_name='hodnoceni', on_delete=models.PROTECT) + feedback = models.TextField('zpětná vazba', blank=True, default='', help_text='Zpětná vazba řešiteli (plain text)') + def __str__(self): return "{}, {}, {}".format(self.problem, self.reseni, self.body)
ProblémBodyDeadline pro body
ProblémBodyZpětná vazba od opravovateleDeadline pro body
{{ h.problem }} {{ h.body }}{{ h.feedback }}{{ h.deadline_body }}