|
@ -7,7 +7,7 @@ from django.core.exceptions import PermissionDenied, ObjectDoesNotExist |
|
|
from django.views import generic |
|
|
from django.views import generic |
|
|
from django.utils.translation import ugettext as _ |
|
|
from django.utils.translation import ugettext as _ |
|
|
from django.http import Http404,HttpResponseBadRequest,HttpResponseRedirect |
|
|
from django.http import Http404,HttpResponseBadRequest,HttpResponseRedirect |
|
|
from django.db.models import Q |
|
|
from django.db.models import Q, Sum, Count |
|
|
from django.views.decorators.csrf import ensure_csrf_cookie |
|
|
from django.views.decorators.csrf import ensure_csrf_cookie |
|
|
from django.contrib.auth import authenticate, login, get_user_model, logout |
|
|
from django.contrib.auth import authenticate, login, get_user_model, logout |
|
|
from django.contrib.auth import views as auth_views |
|
|
from django.contrib.auth import views as auth_views |
|
@ -45,6 +45,45 @@ def verejna_temata(rocnik): |
|
|
""" |
|
|
""" |
|
|
return Problem.objects.filter(typ=Problem.TYP_TEMA, cislo_zadani__rocnik=rocnik, cislo_zadani__verejne_db=True).order_by('kod') |
|
|
return Problem.objects.filter(typ=Problem.TYP_TEMA, cislo_zadani__rocnik=rocnik, cislo_zadani__verejne_db=True).order_by('kod') |
|
|
|
|
|
|
|
|
|
|
|
def temata_v_rocniku(rocnik): |
|
|
|
|
|
return Problem.objects.filter(typ=Problem.TYP_TEMA, rocnik=rocnik) |
|
|
|
|
|
|
|
|
|
|
|
def get_problemy_k_tematu(tema): |
|
|
|
|
|
return Problemy.objects.filter(nadproblem = tema) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VlozBodyView(generic.ListView): |
|
|
|
|
|
template_name = 'seminar/org/vloz_body.html' |
|
|
|
|
|
|
|
|
|
|
|
def get_queryset(self): |
|
|
|
|
|
self.tema = get_object_or_404(Problem,id=self.kwargs['tema']) |
|
|
|
|
|
print(self.tema) |
|
|
|
|
|
self.problemy = Problem.objects.filter(nadproblem = self.tema) |
|
|
|
|
|
print(self.problemy) |
|
|
|
|
|
self.reseni = Reseni.objects.filter(problem__in=self.problemy) |
|
|
|
|
|
print(self.reseni) |
|
|
|
|
|
return self.reseni |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ObalkovaniView(generic.ListView): |
|
|
|
|
|
template_name = 'seminar/org/obalkovani.html' |
|
|
|
|
|
|
|
|
|
|
|
def get_queryset(self): |
|
|
|
|
|
rocnik = get_object_or_404(Rocnik,rocnik=self.kwargs['rocnik']) |
|
|
|
|
|
cislo = get_object_or_404(Cislo,rocnik=rocnik,poradi=self.kwargs['cislo']) |
|
|
|
|
|
self.cislo = cislo |
|
|
|
|
|
self.hodnoceni = s.Hodnoceni.objects.filter(cislo_body=cislo) |
|
|
|
|
|
self.reseni = Reseni.objects.filter(hodnoceni__in = self.hodnoceni).annotate(Sum('hodnoceni__body')).annotate(Count('hodnoceni')).order_by('resitele__osoba') |
|
|
|
|
|
return self.reseni |
|
|
|
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs): |
|
|
|
|
|
context = super(ObalkovaniView, self).get_context_data(**kwargs) |
|
|
|
|
|
print(self.cislo) |
|
|
|
|
|
context['cislo'] = self.cislo |
|
|
|
|
|
return context |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def AktualniZadaniView(request): |
|
|
def AktualniZadaniView(request): |
|
|
nastaveni = get_object_or_404(Nastaveni) |
|
|
nastaveni = get_object_or_404(Nastaveni) |
|
@ -740,7 +779,7 @@ def obalkyView(request,resitele): |
|
|
return response |
|
|
return response |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def obalkovaniView(request, rocnik, cislo): |
|
|
def oldObalkovaniView(request, rocnik, cislo): |
|
|
rocnik = Rocnik.objects.get(rocnik=rocnik) |
|
|
rocnik = Rocnik.objects.get(rocnik=rocnik) |
|
|
cislo = Cislo.objects.get(rocnik=rocnik, cislo=cislo) |
|
|
cislo = Cislo.objects.get(rocnik=rocnik, cislo=cislo) |
|
|
|
|
|
|
|
|