Browse Source

Automatické nastavení deadlinu u Hodnocení, orgovská úprava deadlinů u Hodnocení

pull/3/head
Jonas Havelka 2 years ago
parent
commit
79d9636c28
  1. 2
      odevzdavatko/forms.py
  2. 6
      odevzdavatko/templates/odevzdavatko/detail.html
  3. 4
      odevzdavatko/templates/odevzdavatko/detail_resitele.html
  4. 11
      odevzdavatko/views.py

2
odevzdavatko/forms.py

@ -87,7 +87,7 @@ ReseniSPrilohamiFormSet = inlineformset_factory(m.Reseni,m.PrilohaReseni,
class JednoHodnoceniForm(forms.ModelForm):
class Meta:
model = m.Hodnoceni
fields = ('problem', 'body', 'cislo_body')
fields = ('problem', 'body', 'deadline_body')
widgets = {
'problem': autocomplete.ModelSelect2(
url='autocomplete_problem_odevzdatelny', # FIXME: Dovolit i starší?

6
odevzdavatko/templates/odevzdavatko/detail.html

@ -97,13 +97,13 @@ $(document).ready(function(){
{{ form.management_form }}
</table>
<table id="form_set">
<tr><th>Problém</th><th>Body</th><th>Číslo pro body</th></tr>
<tr><th>Problém</th><th>Body</th><th>Deadline pro body</th></tr>
{% for subform in form %}
<tbody>
<tr class="hodnoceni">
<td>{{ subform.problem }}</td>
<td>{{ subform.body }}</td>
<td>{{ subform.cislo_body }}</td>
<td>{{ subform.deadline_body }}</td>
<td><a href="#" class="smazat_hodnoceni" id="id_{{subform.prefix}}-jsremove"><img src="{% static "odevzdavatko/cross.png" %}" alt="Smazat"></a></td>
</tr>
</tbody>
@ -118,7 +118,7 @@ $(document).ready(function(){
<tr class="hodnoceni">
<td>{{ form.empty_form.problem }}</td>
<td>{{ form.empty_form.body }}</td>
<td>{{ form.empty_form.cislo_body }}</td>
<td>{{ form.empty_form.deadline_body }}</td>
<td><a href="#" class="smazat_hodnoceni" id="id_{{form.empty_form.prefix}}-jsremove"><img src="{% static "odevzdavatko/cross.png" %}" alt="Smazat"></a></td>
</tr>
</table>

4
odevzdavatko/templates/odevzdavatko/detail_resitele.html

@ -37,12 +37,12 @@
{# Hodnocení: #}
<h3>Hodnocení:</h3>
<table id="form_set" class="dosla_reseni">
<tr><th>Problém</th><th>Body</th>{# <th>Číslo pro body</th> #}</tr>
<tr><th>Problém</th><th>Body</th>{# <th>Deadline pro body</th> #}</tr>
{% for h in hodnoceni %}
<tr class="hodnoceni">
<td>{{ h.problem }}</td>
<td>{{ h.body }}</td>
{# <td>{{ h.cislo_body }}</td>#}
{# <td>{{ h.deadline_body }}</td>#}
</tr>
{% endfor %}
</table>

11
odevzdavatko/views.py

@ -216,12 +216,12 @@ class DetailReseniView(DetailView):
def aktualni_hodnoceni(self):
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):
result.append(
{"problem": hodn.problem,
"body": hodn.body,
"cislo_body": hodn.cislo_body,
"deadline_body": hodn.deadline_body,
})
return result
@ -260,11 +260,11 @@ def hodnoceniReseniView(request, pk, *args, **kwargs):
for form in formset:
problem = form.cleaned_data['problem']
body = form.cleaned_data['body']
cislo_body = form.cleaned_data['cislo_body']
deadline_body = form.cleaned_data['deadline_body']
hodnoceni = m.Hodnoceni(
problem=problem,
body=body,
cislo_body=cislo_body,
deadline_body=deadline_body,
reseni=reseni,
)
logger.info(f"Creating Hodnoceni: {hodnoceni}")
@ -285,7 +285,7 @@ class ResitelReseniView(DetailView):
{
"problem": hodn.problem,
"body": hodn.body,
# "cislo_body": hodn.cislo_body,
# "deadline_body": hodn.deadline_body,
}
)
return result
@ -412,6 +412,7 @@ class NahrajReseniView(LoginRequiredMixin, CreateView):
self.object = form.save()
self.object.resitele.add(m.Resitel.objects.get(osoba__user = self.request.user))
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.save()

Loading…
Cancel
Save