práce na archivu

This commit is contained in:
Kateřina Čížková 2020-04-04 10:54:20 +02:00
parent 63c6839a71
commit 835f35a44c
4 changed files with 67 additions and 44 deletions

View file

@ -38,7 +38,7 @@
Jednotlivá čísla: Jednotlivá čísla:
<ul> <ul>
{% for cislo in rocnik.cisla.all reversed %} {% for cislo in rocnik.cisla.all reversed %}
<li><a href='{{ cislo.verejne_url }}'>{{ cislo.poradi }}. číslo</a> {% if cislo.pdf %}(<a href='{{ cislo.pdf }}'>pdf</a>) {% endif %} <!-- FIXME: cislo.pdf--> <li><a href='{{ cislo.verejne_url }}'>{{ cislo.poradi }}. číslo</a> {% if cislo.pdf %}(<a href='{{ cislo.pdf.url }}'>pdf</a>) {% endif %}
{% empty %} {% empty %}
--- ---
{% endfor %} {% endfor %}
@ -49,7 +49,8 @@
</div> </div>
</div> </div>
</div> </div>
{# konec karty organizátora #}
{# konec karty ročníku #}
<hr> <hr>
</div> </div>

View file

@ -96,4 +96,3 @@
</div> </div>
{% endblock content %} {% endblock content %}

View file

@ -2,22 +2,11 @@
{% block content %} {% block content %}
<div> <div>
<h1> <h2>
{% block nadpis1a %}{% block nadpis1b %} {% block nadpis1a %}{% block nadpis1b %}
Ročník {{ rocnik.roman }} Ročník {{ rocnik }}
{% endblock %}{% endblock %} {% endblock %}{% endblock %}
</h1> </h2>
<p>Ročník číslo {{ rocnik.rocnik }} ({{ rocnik.prvni_rok }}/{{ rocnik.druhy_rok }})
<ul>
{% for c in rocnik.verejna_cisla %}
<li><a href="{{ c.verejne_url }}">Číslo {{ c.kod }}</a>
{% if c.pdf %}
(<a href='{{ c.pdf.url }}'>pdf</a>)
{% endif %}
{% endfor %}
</ul>
{% if temata_v_rocniku %} {% if temata_v_rocniku %}
<h2>Témata</h2> <h2>Témata</h2>
@ -28,6 +17,15 @@
</ul> </ul>
{% endif %} {% endif %}
<ul>
{% for c in rocnik.verejna_cisla %}
<li><a href="{{ c.verejne_url }}">Číslo {{ c.kod }}</a>
{% if c.pdf %}
(<a href='{{ c.pdf.url }}'>pdf</a>)
{% endif %}
{% endfor %}
</ul>
{% if vysledkovka %} {% if vysledkovka %}
{% if user.is_staff %} {% if user.is_staff %}
<div class='mam-org-only'> <div class='mam-org-only'>
@ -50,7 +48,3 @@
</div> </div>
{% endblock content %} {% endblock content %}

View file

@ -320,6 +320,33 @@ class ArchivView(generic.ListView):
# slovník {(ročník, url obrázku)} # slovník {(ročník, url obrázku)}
urls ={} 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): for i,c in enumerate(cisla):
if not c.pdf: if not c.pdf:
urls[c.rocnik] = op.join(settings.MEDIA_URL, "cislo", "png", "default.png") urls[c.rocnik] = op.join(settings.MEDIA_URL, "cislo", "png", "default.png")
@ -346,6 +373,8 @@ class ArchivView(generic.ListView):
context["object_list"] = urls context["object_list"] = urls
print(context)
# for i, c in enumerate(cisla): # for i, c in enumerate(cisla):
# if not c.pdf: # if not c.pdf:
# continue # continue