From 835f35a44c3c867192db3bf8d9a3f70b61f66aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kate=C5=99ina=20=C4=8C=C3=AD=C5=BEkov=C3=A1?= Date: Sat, 4 Apr 2020 10:54:20 +0200 Subject: [PATCH] =?UTF-8?q?pr=C3=A1ce=20na=20archivu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/templates/seminar/archiv/cisla.html | 5 +- seminar/templates/seminar/archiv/cislo.html | 9 ++- seminar/templates/seminar/archiv/rocnik.html | 28 +++----- seminar/views/views_all.py | 73 ++++++++++++++------ 4 files changed, 69 insertions(+), 46 deletions(-) diff --git a/seminar/templates/seminar/archiv/cisla.html b/seminar/templates/seminar/archiv/cisla.html index be860f81..3c4a38b4 100644 --- a/seminar/templates/seminar/archiv/cisla.html +++ b/seminar/templates/seminar/archiv/cisla.html @@ -38,7 +38,7 @@ Jednotlivá čísla: - {% endif %} + {% endif %} {% if cislo.verejna_vysledkovka %}

Výsledkovka ({% now "jS F Y H:i" %})

@@ -86,7 +86,7 @@ {% endfor %} - {% endif %} + {% endif %} {% if not cislo.verejna_vysledkovka and user.is_staff %} @@ -94,6 +94,5 @@ Čas: {% now "jS F Y H:i:s" %} - -{% endblock content %} - + +{% endblock content %} diff --git a/seminar/templates/seminar/archiv/rocnik.html b/seminar/templates/seminar/archiv/rocnik.html index 64c4029d..c6165941 100644 --- a/seminar/templates/seminar/archiv/rocnik.html +++ b/seminar/templates/seminar/archiv/rocnik.html @@ -2,13 +2,20 @@ {% block content %}
-

+

{% block nadpis1a %}{% block nadpis1b %} - Ročník {{ rocnik.roman }} + Ročník {{ rocnik }} {% endblock %}{% endblock %} -

+ -

Ročník číslo {{ rocnik.rocnik }} ({{ rocnik.prvni_rok }}/{{ rocnik.druhy_rok }}) + {% if temata_v_rocniku %} +

Témata

+ + {% endif %} - {% if temata_v_rocniku %} -

Témata

- - {% endif %} - {% if vysledkovka %} {% if user.is_staff %}
@@ -50,7 +48,3 @@
{% endblock content %} - - - - diff --git a/seminar/views/views_all.py b/seminar/views/views_all.py index 9fe65ca0..81c8d55e 100644 --- a/seminar/views/views_all.py +++ b/seminar/views/views_all.py @@ -320,32 +320,61 @@ class ArchivView(generic.ListView): # slovník {(ročník, url obrázku)} urls ={} + # for j, rocnik in enumerate(Rocnik.objects.all()): + # urls_rocnik = {} + # for i,c in enumerate(rocnik.cisla.all()): + # if not c.pdf: + # urls_rocnik[c.poradi] = op.join(settings.MEDIA_URL, "cislo", "png", "default.png") + # else: + # filename = os.path.split(c.pdf.file.name)[1].split(".")[0] + # png_filename = "{}.png".format(filename) + + # # Pokud obrázek neexistuje nebo není aktuální, vytvoř jej + # png_path = op.join(png_dir, png_filename) + # if not op.exists(png_path) or \ + # op.getmtime(png_path) < op.getmtime(c.pdf.path): + + # subprocess.call([ + # "convert", + # "-density", "300x300", + # "-geometry", "{}x{}".format(vyska, sirka), + # "-background", "white", + # "-flatten", + # "{}[0]".format(c.pdf.path), # titulní strana + # png_path + # ]) + + # urls_rocnik[c.poradi] = op.join(settings.MEDIA_URL, "cislo", "png", png_filename) + # urls[rocnik] = urls_rocnik + for i,c in enumerate(cisla): - if not c.pdf: - urls[c.rocnik] = op.join(settings.MEDIA_URL, "cislo", "png", "default.png") - else: - filename = os.path.split(c.pdf.file.name)[1].split(".")[0] - png_filename = "{}.png".format(filename) - - # Pokud obrázek neexistuje nebo není aktuální, vytvoř jej - png_path = op.join(png_dir, png_filename) - if not op.exists(png_path) or \ - op.getmtime(png_path) < op.getmtime(c.pdf.path): - - subprocess.call([ - "convert", - "-density", "300x300", - "-geometry", "{}x{}".format(vyska, sirka), - "-background", "white", - "-flatten", - "{}[0]".format(c.pdf.path), # titulní strana - png_path - ]) - - urls[c.rocnik] = op.join(settings.MEDIA_URL, "cislo", "png", png_filename) + if not c.pdf: + urls[c.rocnik] = op.join(settings.MEDIA_URL, "cislo", "png", "default.png") + else: + filename = os.path.split(c.pdf.file.name)[1].split(".")[0] + png_filename = "{}.png".format(filename) + + # Pokud obrázek neexistuje nebo není aktuální, vytvoř jej + png_path = op.join(png_dir, png_filename) + if not op.exists(png_path) or \ + op.getmtime(png_path) < op.getmtime(c.pdf.path): + + subprocess.call([ + "convert", + "-density", "300x300", + "-geometry", "{}x{}".format(vyska, sirka), + "-background", "white", + "-flatten", + "{}[0]".format(c.pdf.path), # titulní strana + png_path + ]) + + urls[c.rocnik] = op.join(settings.MEDIA_URL, "cislo", "png", png_filename) context["object_list"] = urls + print(context) + # for i, c in enumerate(cisla): # if not c.pdf: # continue