|
@ -6,7 +6,7 @@ from django.core.urlresolvers import reverse |
|
|
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist |
|
|
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 |
|
|
from django.http import Http404,HttpResponseBadRequest |
|
|
from django.db.models import Q |
|
|
from django.db.models import Q |
|
|
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 |
|
|
from django.contrib.auth import authenticate, login |
|
@ -530,7 +530,7 @@ class SoustredeniView(generic.DetailView): |
|
|
template_name = 'seminar/archiv/soustredeni.html' |
|
|
template_name = 'seminar/archiv/soustredeni.html' |
|
|
|
|
|
|
|
|
def soustredeniObalkyView(request,soustredeni): |
|
|
def soustredeniObalkyView(request,soustredeni): |
|
|
soustredeni = Soustredeni.objects.filter(id = soustredeni)[0] |
|
|
soustredeni = get_object_or_404(Soustredeni,id = soustredeni) |
|
|
return obalkyView(request,soustredeni.ucastnici.all()) |
|
|
return obalkyView(request,soustredeni.ucastnici.all()) |
|
|
|
|
|
|
|
|
class SoustredeniUcastniciView(generic.ListView): |
|
|
class SoustredeniUcastniciView(generic.ListView): |
|
@ -541,8 +541,30 @@ class SoustredeniUcastniciView(generic.ListView): |
|
|
self.soustredeni = get_object_or_404(Soustredeni, id=self.kwargs["soustredeni"]) |
|
|
self.soustredeni = get_object_or_404(Soustredeni, id=self.kwargs["soustredeni"]) |
|
|
return Soustredeni_Ucastnici.objects.filter(soustredeni=self.soustredeni).select_related('resitel') |
|
|
return Soustredeni_Ucastnici.objects.filter(soustredeni=self.soustredeni).select_related('resitel') |
|
|
|
|
|
|
|
|
|
|
|
def soustredeniStvrzenkyExportView(request,soustredeni,first_num): |
|
|
|
|
|
first_num = int(first_num) |
|
|
|
|
|
soustredeni = get_object_or_404(Soustredeni,id = soustredeni) |
|
|
|
|
|
ucastnici = Resitel.objects.filter(soustredeni=soustredeni) |
|
|
|
|
|
for (idx,u) in enumerate(ucastnici): |
|
|
|
|
|
u.cislo_stvrzenky = first_num+idx; |
|
|
|
|
|
tex = render(request,'seminar/soustredeni/ucastnici.tex', {'ucastnici': ucastnici, 'datum':soustredeni.datum_zacatku }).content |
|
|
|
|
|
|
|
|
|
|
|
tempdir = tempfile.mkdtemp() |
|
|
|
|
|
with open(tempdir+"/ucastnici.tex","w") as texfile: |
|
|
|
|
|
# Pokud TeX chce ISO Latin, tak se da encode nastavit |
|
|
|
|
|
texfile.write(tex.decode("utf-8").encode("utf-8")) |
|
|
|
|
|
shutil.copy(os.path.join(settings.STATIC_ROOT, 'seminar/stvrzenka.sty'),tempdir) |
|
|
|
|
|
shutil.copy(os.path.join(settings.STATIC_ROOT, 'seminar/stvrzenky.tex'),tempdir) |
|
|
|
|
|
subprocess.call(["pdfcslatex","stvrzenky.tex"],cwd = tempdir) |
|
|
|
|
|
|
|
|
|
|
|
with open(tempdir+"/stvrzenky.pdf","rb") as pdffile: |
|
|
|
|
|
response = HttpResponse(pdffile.read(),content_type='application/pdf') |
|
|
|
|
|
shutil.rmtree(tempdir) |
|
|
|
|
|
return response |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def soustredeniUcastniciExportView(request,soustredeni): |
|
|
def soustredeniUcastniciExportView(request,soustredeni): |
|
|
soustredeni = Soustredeni.objects.filter(id = soustredeni)[0] |
|
|
soustredeni = get_object_or_404(Soustredeni,id = soustredeni) |
|
|
ucastnici = Resitel.objects.filter(soustredeni=soustredeni) |
|
|
ucastnici = Resitel.objects.filter(soustredeni=soustredeni) |
|
|
response = HttpResponse(content_type='text/csv') |
|
|
response = HttpResponse(content_type='text/csv') |
|
|
response['Content-Disposition'] = 'attachment; filename="ucastnici.csv"' |
|
|
response['Content-Disposition'] = 'attachment; filename="ucastnici.csv"' |
|
|