views, old_views: přesunutí některých nepoužívaných views do separátního souboru, aby nepřekážely
This commit is contained in:
parent
c16a07cdf3
commit
ecfc5e6905
2 changed files with 71 additions and 66 deletions
71
seminar/old_views.py
Normal file
71
seminar/old_views.py
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
# Tento soubor slouží k odkládání aktuálně nepotřebného kódu, který by
|
||||||
|
# se však v budoucnu mohl opět hodit.
|
||||||
|
|
||||||
|
###################################################################
|
||||||
|
|
||||||
|
## Prispevek byl zrusen, mozna ale bude podobny nahled na neco jineho.
|
||||||
|
#class PrispevekView(generic.DetailView):
|
||||||
|
# model = Prispevek
|
||||||
|
# template_name = 'seminar/archiv/prispevek.html'
|
||||||
|
#
|
||||||
|
# # Vlastni ziskavani objektu z databaze podle prispevku
|
||||||
|
# # pokud je prispevek neverejny zobrazi se jenom orgum
|
||||||
|
# def get_object(self, queryset=None):
|
||||||
|
# if queryset is None:
|
||||||
|
# queryset = self.get_queryset()
|
||||||
|
# problem_arg = self.kwargs.get('pk')
|
||||||
|
# prispevek_arg = self.kwargs.get('prispevek')
|
||||||
|
# queryset = queryset.filter(pk=prispevek_arg)
|
||||||
|
#
|
||||||
|
# try:
|
||||||
|
# obj = queryset.get()
|
||||||
|
# except queryset.model.DoesNotExist:
|
||||||
|
# raise Http404(_("No %(verbose_name)s found matching the query") %
|
||||||
|
# {'verbose_name': queryset.model._meta.verbose_name})
|
||||||
|
#
|
||||||
|
# if self.request.user.is_staff or obj.zverejnit:
|
||||||
|
# return obj
|
||||||
|
# else:
|
||||||
|
# raise Http404()
|
||||||
|
#
|
||||||
|
# def get_context_data(self, **kwargs):
|
||||||
|
# context = super(PrispevekView, self).get_context_data(**kwargs)
|
||||||
|
# # snaho o ziskani titulu
|
||||||
|
# titul = ''
|
||||||
|
# try:
|
||||||
|
# resitel = context['prispevek'].reseni.resitel
|
||||||
|
# cislo = context['prispevek'].reseni.cislo_body
|
||||||
|
# body = VysledkyKCisluOdjakziva.objects.get(resitel=resitel,
|
||||||
|
# cislo=cislo).body
|
||||||
|
# titul = resitel.get_titul(body)
|
||||||
|
# except:
|
||||||
|
# pass
|
||||||
|
# context['titul'] = titul
|
||||||
|
# return context
|
||||||
|
|
||||||
|
####################################################################
|
||||||
|
|
||||||
|
## Stvrzenky aktuálně nevydáváme, ale možná časem zase budeme.
|
||||||
|
#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(["cslatex","stvrzenky.tex"],cwd = tempdir)
|
||||||
|
# subprocess.call(["dvipdf","stvrzenky.dvi"],cwd = tempdir)
|
||||||
|
#
|
||||||
|
# with open(tempdir+"/stvrzenky.pdf","rb") as pdffile:
|
||||||
|
# response = HttpResponse(pdffile.read(),content_type='application/pdf')
|
||||||
|
# shutil.rmtree(tempdir)
|
||||||
|
# return response
|
||||||
|
|
||||||
|
|
|
@ -377,47 +377,6 @@ class ProblemView(generic.DetailView):
|
||||||
context['reseni'] = Reseni.objects.filter(problem=context['problem']).select_related('resitel').order_by('resitel__prijmeni')
|
context['reseni'] = Reseni.objects.filter(problem=context['problem']).select_related('resitel').order_by('resitel__prijmeni')
|
||||||
return context
|
return context
|
||||||
|
|
||||||
## Prispevek byl zrusen, mozna ale bude podobny nahled na neco jineho.
|
|
||||||
#class PrispevekView(generic.DetailView):
|
|
||||||
# model = Prispevek
|
|
||||||
# template_name = 'seminar/archiv/prispevek.html'
|
|
||||||
#
|
|
||||||
# # Vlastni ziskavani objektu z databaze podle prispevku
|
|
||||||
# # pokud je prispevek neverejny zobrazi se jenom orgum
|
|
||||||
# def get_object(self, queryset=None):
|
|
||||||
# if queryset is None:
|
|
||||||
# queryset = self.get_queryset()
|
|
||||||
# problem_arg = self.kwargs.get('pk')
|
|
||||||
# prispevek_arg = self.kwargs.get('prispevek')
|
|
||||||
# queryset = queryset.filter(pk=prispevek_arg)
|
|
||||||
#
|
|
||||||
# try:
|
|
||||||
# obj = queryset.get()
|
|
||||||
# except queryset.model.DoesNotExist:
|
|
||||||
# raise Http404(_("No %(verbose_name)s found matching the query") %
|
|
||||||
# {'verbose_name': queryset.model._meta.verbose_name})
|
|
||||||
#
|
|
||||||
# if self.request.user.is_staff or obj.zverejnit:
|
|
||||||
# return obj
|
|
||||||
# else:
|
|
||||||
# raise Http404()
|
|
||||||
#
|
|
||||||
# def get_context_data(self, **kwargs):
|
|
||||||
# context = super(PrispevekView, self).get_context_data(**kwargs)
|
|
||||||
# # snaho o ziskani titulu
|
|
||||||
# titul = ''
|
|
||||||
# try:
|
|
||||||
# resitel = context['prispevek'].reseni.resitel
|
|
||||||
# cislo = context['prispevek'].reseni.cislo_body
|
|
||||||
# body = VysledkyKCisluOdjakziva.objects.get(resitel=resitel,
|
|
||||||
# cislo=cislo).body
|
|
||||||
# titul = resitel.get_titul(body)
|
|
||||||
# except:
|
|
||||||
# pass
|
|
||||||
# context['titul'] = titul
|
|
||||||
# return context
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RadekVysledkovky(object):
|
class RadekVysledkovky(object):
|
||||||
pass
|
pass
|
||||||
|
@ -465,7 +424,6 @@ class RadekVysledkovky(object):
|
||||||
# #setridi problemy podle typu a poradi zadani
|
# #setridi problemy podle typu a poradi zadani
|
||||||
# problem_index = {}
|
# problem_index = {}
|
||||||
# for i in range(len(problemy)):
|
# for i in range(len(problemy)):
|
||||||
# problem_index[problemy[i].id] = i
|
|
||||||
# #umoznuje zjistit index podle id problemu
|
# #umoznuje zjistit index podle id problemu
|
||||||
#
|
#
|
||||||
# vysledky_resitele = {}
|
# vysledky_resitele = {}
|
||||||
|
@ -665,30 +623,6 @@ class SoustredeniUcastniciView(SoustredeniUcastniciBaseView):
|
||||||
model = Soustredeni_Ucastnici
|
model = Soustredeni_Ucastnici
|
||||||
template_name = 'seminar/soustredeni/seznam_ucastniku.html'
|
template_name = 'seminar/soustredeni/seznam_ucastniku.html'
|
||||||
|
|
||||||
|
|
||||||
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(["cslatex","stvrzenky.tex"],cwd = tempdir)
|
|
||||||
subprocess.call(["dvipdf","stvrzenky.dvi"],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 = get_object_or_404(Soustredeni,id = soustredeni)
|
soustredeni = get_object_or_404(Soustredeni,id = soustredeni)
|
||||||
ucastnici = Resitel.objects.filter(soustredeni=soustredeni)
|
ucastnici = Resitel.objects.filter(soustredeni=soustredeni)
|
||||||
|
|
Loading…
Reference in a new issue