|
@ -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 |
|
|