práce na archivu
This commit is contained in:
		
							parent
							
								
									63c6839a71
								
							
						
					
					
						commit
						835f35a44c
					
				
					 4 changed files with 67 additions and 44 deletions
				
			
		|  | @ -38,7 +38,7 @@ | |||
|         Jednotlivá čísla: | ||||
|         <ul> | ||||
|           {% 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 %} | ||||
|             --- | ||||
|           {% endfor %} | ||||
|  | @ -49,7 +49,8 @@ | |||
|       </div> | ||||
|       </div> | ||||
|       </div> | ||||
|       {# konec karty organizátora #} | ||||
| 
 | ||||
|       {# konec karty ročníku #} | ||||
| 
 | ||||
|     <hr> | ||||
|     </div> | ||||
|  |  | |||
|  | @ -46,7 +46,7 @@ | |||
|           <li><a href="obalkovani">Obálkování</a></li> | ||||
|         </ul> | ||||
|       </div> | ||||
|   {% endif %}  | ||||
|   {% endif %} | ||||
| 
 | ||||
|   {% if cislo.verejna_vysledkovka %} | ||||
|   <h2>Výsledkovka ({% now "jS F Y H:i" %})</h2> | ||||
|  | @ -86,7 +86,7 @@ | |||
|       </tr> | ||||
|     {% endfor %} | ||||
|     </table> | ||||
|   {% endif %}  | ||||
|   {% endif %} | ||||
| 
 | ||||
|   {% if not cislo.verejna_vysledkovka and user.is_staff %} | ||||
|       </div> | ||||
|  | @ -94,6 +94,5 @@ | |||
| 
 | ||||
|   Čas: {% now "jS F Y H:i:s" %} | ||||
| 
 | ||||
| </div>  | ||||
| {% endblock content %}  | ||||
| 
 | ||||
| </div> | ||||
| {% endblock content %} | ||||
|  |  | |||
|  | @ -2,22 +2,11 @@ | |||
| 
 | ||||
| {% block content %} | ||||
| <div> | ||||
|   <h1> | ||||
|   <h2> | ||||
|     {% block nadpis1a %}{% block nadpis1b %} | ||||
|       Ročník {{ rocnik.roman }} | ||||
|       Ročník {{ rocnik }} | ||||
|     {% endblock %}{% endblock %} | ||||
|   </h1> | ||||
| 
 | ||||
|   <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> | ||||
|   </h2> | ||||
| 
 | ||||
|   {% if temata_v_rocniku %} | ||||
|     <h2>Témata</h2> | ||||
|  | @ -28,6 +17,15 @@ | |||
|     </ul> | ||||
|   {% 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 user.is_staff %} | ||||
|       <div class='mam-org-only'> | ||||
|  | @ -50,7 +48,3 @@ | |||
| 
 | ||||
| </div> | ||||
| {% endblock content %} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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) | ||||
| 				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): | ||||
| 					# 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 | ||||
| 					]) | ||||
| 						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) | ||||
| 					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 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Kateřina Čížková
						Kateřina Čížková