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 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ší?
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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…
Reference in a new issue