From ecfc5e6905f9bf3fa3e85feae9dd559e10516837 Mon Sep 17 00:00:00 2001 From: Anet Date: Mon, 10 Jun 2019 23:40:31 +0200 Subject: [PATCH] =?UTF-8?q?views,=20old=5Fviews:=20p=C5=99esunut=C3=AD=20n?= =?UTF-8?q?=C4=9Bkter=C3=BDch=20nepou=C5=BE=C3=ADvan=C3=BDch=20views=20do?= =?UTF-8?q?=20separ=C3=A1tn=C3=ADho=20souboru,=20aby=20nep=C5=99ek=C3=A1?= =?UTF-8?q?=C5=BEely?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/old_views.py | 71 ++++++++++++++++++++++++++++++++++++++++++++ seminar/views.py | 66 ---------------------------------------- 2 files changed, 71 insertions(+), 66 deletions(-) create mode 100644 seminar/old_views.py diff --git a/seminar/old_views.py b/seminar/old_views.py new file mode 100644 index 00000000..f904d137 --- /dev/null +++ b/seminar/old_views.py @@ -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 + + diff --git a/seminar/views.py b/seminar/views.py index 3f01376f..aba2b55e 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -377,47 +377,6 @@ class ProblemView(generic.DetailView): context['reseni'] = Reseni.objects.filter(problem=context['problem']).select_related('resitel').order_by('resitel__prijmeni') 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): pass @@ -465,7 +424,6 @@ class RadekVysledkovky(object): # #setridi problemy podle typu a poradi zadani # problem_index = {} # for i in range(len(problemy)): -# problem_index[problemy[i].id] = i # #umoznuje zjistit index podle id problemu # # vysledky_resitele = {} @@ -665,30 +623,6 @@ class SoustredeniUcastniciView(SoustredeniUcastniciBaseView): model = Soustredeni_Ucastnici 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): soustredeni = get_object_or_404(Soustredeni,id = soustredeni) ucastnici = Resitel.objects.filter(soustredeni=soustredeni)