Automatické nastavení deadlinu u Hodnocení, orgovská úprava deadlinů u Hodnocení
This commit is contained in:
parent
05047d547a
commit
79d9636c28
4 changed files with 12 additions and 11 deletions
|
@ -87,7 +87,7 @@ ReseniSPrilohamiFormSet = inlineformset_factory(m.Reseni,m.PrilohaReseni,
|
||||||
class JednoHodnoceniForm(forms.ModelForm):
|
class JednoHodnoceniForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = m.Hodnoceni
|
model = m.Hodnoceni
|
||||||
fields = ('problem', 'body', 'cislo_body')
|
fields = ('problem', 'body', 'deadline_body')
|
||||||
widgets = {
|
widgets = {
|
||||||
'problem': autocomplete.ModelSelect2(
|
'problem': autocomplete.ModelSelect2(
|
||||||
url='autocomplete_problem_odevzdatelny', # FIXME: Dovolit i starší?
|
url='autocomplete_problem_odevzdatelny', # FIXME: Dovolit i starší?
|
||||||
|
|
|
@ -97,13 +97,13 @@ $(document).ready(function(){
|
||||||
{{ form.management_form }}
|
{{ form.management_form }}
|
||||||
</table>
|
</table>
|
||||||
<table id="form_set">
|
<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 %}
|
{% for subform in form %}
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class="hodnoceni">
|
<tr class="hodnoceni">
|
||||||
<td>{{ subform.problem }}</td>
|
<td>{{ subform.problem }}</td>
|
||||||
<td>{{ subform.body }}</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>
|
<td><a href="#" class="smazat_hodnoceni" id="id_{{subform.prefix}}-jsremove"><img src="{% static "odevzdavatko/cross.png" %}" alt="Smazat"></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -118,7 +118,7 @@ $(document).ready(function(){
|
||||||
<tr class="hodnoceni">
|
<tr class="hodnoceni">
|
||||||
<td>{{ form.empty_form.problem }}</td>
|
<td>{{ form.empty_form.problem }}</td>
|
||||||
<td>{{ form.empty_form.body }}</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>
|
<td><a href="#" class="smazat_hodnoceni" id="id_{{form.empty_form.prefix}}-jsremove"><img src="{% static "odevzdavatko/cross.png" %}" alt="Smazat"></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -37,12 +37,12 @@
|
||||||
{# Hodnocení: #}
|
{# Hodnocení: #}
|
||||||
<h3>Hodnocení:</h3>
|
<h3>Hodnocení:</h3>
|
||||||
<table id="form_set" class="dosla_reseni">
|
<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 %}
|
{% for h in hodnoceni %}
|
||||||
<tr class="hodnoceni">
|
<tr class="hodnoceni">
|
||||||
<td>{{ h.problem }}</td>
|
<td>{{ h.problem }}</td>
|
||||||
<td>{{ h.body }}</td>
|
<td>{{ h.body }}</td>
|
||||||
{# <td>{{ h.cislo_body }}</td>#}
|
{# <td>{{ h.deadline_body }}</td>#}
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -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()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue