|
@ -216,12 +216,12 @@ class DetailReseniView(DetailView): |
|
|
|
|
|
|
|
|
def aktualni_hodnoceni(self): |
|
|
def aktualni_hodnoceni(self): |
|
|
self.reseni = get_object_or_404(m.Reseni, id=self.kwargs['pk']) |
|
|
self.reseni = get_object_or_404(m.Reseni, id=self.kwargs['pk']) |
|
|
result = [] # Slovníky s klíči problem, body, cislo_body -- initial data pro f.OhodnoceniReseniFormSet |
|
|
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): |
|
|
for hodn in m.Hodnoceni.objects.filter(reseni=self.reseni): |
|
|
result.append( |
|
|
result.append( |
|
|
{"problem": hodn.problem, |
|
|
{"problem": hodn.problem, |
|
|
"body": hodn.body, |
|
|
"body": hodn.body, |
|
|
"cislo_body": hodn.cislo_body, |
|
|
"deadline_body": hodn.deadline_body, |
|
|
}) |
|
|
}) |
|
|
return result |
|
|
return result |
|
|
|
|
|
|
|
@ -260,11 +260,11 @@ def hodnoceniReseniView(request, pk, *args, **kwargs): |
|
|
for form in formset: |
|
|
for form in formset: |
|
|
problem = form.cleaned_data['problem'] |
|
|
problem = form.cleaned_data['problem'] |
|
|
body = form.cleaned_data['body'] |
|
|
body = form.cleaned_data['body'] |
|
|
cislo_body = form.cleaned_data['cislo_body'] |
|
|
deadline_body = form.cleaned_data['deadline_body'] |
|
|
hodnoceni = m.Hodnoceni( |
|
|
hodnoceni = m.Hodnoceni( |
|
|
problem=problem, |
|
|
problem=problem, |
|
|
body=body, |
|
|
body=body, |
|
|
cislo_body=cislo_body, |
|
|
deadline_body=deadline_body, |
|
|
reseni=reseni, |
|
|
reseni=reseni, |
|
|
) |
|
|
) |
|
|
logger.info(f"Creating Hodnoceni: {hodnoceni}") |
|
|
logger.info(f"Creating Hodnoceni: {hodnoceni}") |
|
@ -285,7 +285,7 @@ class ResitelReseniView(DetailView): |
|
|
{ |
|
|
{ |
|
|
"problem": hodn.problem, |
|
|
"problem": hodn.problem, |
|
|
"body": hodn.body, |
|
|
"body": hodn.body, |
|
|
# "cislo_body": hodn.cislo_body, |
|
|
# "deadline_body": hodn.deadline_body, |
|
|
} |
|
|
} |
|
|
) |
|
|
) |
|
|
return result |
|
|
return result |
|
@ -412,6 +412,7 @@ class NahrajReseniView(LoginRequiredMixin, CreateView): |
|
|
self.object = form.save() |
|
|
self.object = form.save() |
|
|
self.object.resitele.add(m.Resitel.objects.get(osoba__user = self.request.user)) |
|
|
self.object.resitele.add(m.Resitel.objects.get(osoba__user = self.request.user)) |
|
|
self.object.cas_doruceni = timezone.now() |
|
|
self.object.cas_doruceni = timezone.now() |
|
|
|
|
|
self.object.deadline = m.Deadline.objects.filter(deadline__gte=self.object.cas_doruceni).first() |
|
|
self.object.forma = m.Reseni.FORMA_UPLOAD |
|
|
self.object.forma = m.Reseni.FORMA_UPLOAD |
|
|
self.object.save() |
|
|
self.object.save() |
|
|
|
|
|
|
|
|