|
@ -8,7 +8,6 @@ from django.http import Http404 |
|
|
from django.db.models import Q, Sum, Count |
|
|
from django.db.models import Q, Sum, Count |
|
|
from django.views.generic.base import RedirectView |
|
|
from django.views.generic.base import RedirectView |
|
|
from django.core.exceptions import PermissionDenied |
|
|
from django.core.exceptions import PermissionDenied |
|
|
from django.contrib.staticfiles.finders import find |
|
|
|
|
|
|
|
|
|
|
|
import seminar.models as s |
|
|
import seminar.models as s |
|
|
import seminar.models as m |
|
|
import seminar.models as m |
|
@ -26,18 +25,15 @@ from vysledkovky.utils import body_resitelu, VysledkovkaCisla, \ |
|
|
from datetime import date, datetime |
|
|
from datetime import date, datetime |
|
|
from itertools import groupby |
|
|
from itertools import groupby |
|
|
from collections import OrderedDict |
|
|
from collections import OrderedDict |
|
|
import tempfile |
|
|
|
|
|
import subprocess |
|
|
|
|
|
import shutil |
|
|
|
|
|
import os |
|
|
import os |
|
|
import os.path as op |
|
|
import os.path as op |
|
|
from django.conf import settings |
|
|
from django.conf import settings |
|
|
import unicodedata |
|
|
import unicodedata |
|
|
import logging |
|
|
import logging |
|
|
import time |
|
|
import time |
|
|
import http |
|
|
|
|
|
|
|
|
|
|
|
from seminar.utils import aktivniResitele |
|
|
from seminar.utils import aktivniResitele |
|
|
|
|
|
import personalni.views |
|
|
|
|
|
|
|
|
# ze starého modelu |
|
|
# ze starého modelu |
|
|
#def verejna_temata(rocnik): |
|
|
#def verejna_temata(rocnik): |
|
@ -485,31 +481,9 @@ class RocnikVysledkovkaView(RocnikView): |
|
|
|
|
|
|
|
|
def cisloObalkyView(request, rocnik, cislo): |
|
|
def cisloObalkyView(request, rocnik, cislo): |
|
|
realne_cislo = get_object_or_404(Cislo, poradi=cislo, rocnik__rocnik=rocnik) |
|
|
realne_cislo = get_object_or_404(Cislo, poradi=cislo, rocnik__rocnik=rocnik) |
|
|
return obalkyView(request, aktivniResitele(realne_cislo)) |
|
|
return personalni.views.obalkyView(request, aktivniResitele(realne_cislo)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def obalkyView(request, resitele): |
|
|
|
|
|
if len(resitele) == 0: |
|
|
|
|
|
return HttpResponse( |
|
|
|
|
|
render(request, 'universal.html', { |
|
|
|
|
|
'title': 'Není pro koho vyrobit obálky.', |
|
|
|
|
|
'text': 'Právě ses pokusil/a vygenerovat obálky pro prázdnou množinu lidí. Můžeš to zkusit změnit, případně se zeptej webařů :-)', |
|
|
|
|
|
}), |
|
|
|
|
|
status=http.HTTPStatus.NOT_FOUND, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
tex = render(request,'seminar/archiv/obalky.tex', {'resitele': resitele}).content |
|
|
|
|
|
|
|
|
|
|
|
with tempfile.TemporaryDirectory() as tempdir: |
|
|
|
|
|
with open(tempdir+"/obalky.tex","w") as texfile: |
|
|
|
|
|
texfile.write(tex.decode()) |
|
|
|
|
|
shutil.copy(find('seminar/lisak.pdf'), tempdir) |
|
|
|
|
|
subprocess.call(["pdflatex","obalky.tex"], cwd = tempdir) |
|
|
|
|
|
|
|
|
|
|
|
with open(tempdir+"/obalky.pdf","rb") as pdffile: |
|
|
|
|
|
response = HttpResponse(pdffile.read(), content_type='application/pdf') |
|
|
|
|
|
return response |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Tituly |
|
|
### Tituly |
|
|
def TitulyViewRocnik(request, rocnik): |
|
|
def TitulyViewRocnik(request, rocnik): |
|
|