Merge branch 'data_migrations' of gimli.ms.mff.cuni.cz:/akce/mam/git/mamweb into data_migrations
This commit is contained in:
		
						commit
						ec92bee880
					
				
					 4 changed files with 86 additions and 149 deletions
				
			
		|  | @ -51,7 +51,10 @@ a:focus, a:hover, a:active { | ||||||
| 	color: #e84e10; | 	color: #e84e10; | ||||||
| 	text-decoration: none; | 	text-decoration: none; | ||||||
| } | } | ||||||
| a:focus a:hover | 
 | ||||||
|  | img { | ||||||
|  | 	filter: drop-shadow(0px 3px 3px rgba(0, 0, 0, 0.4)); | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| h1 {	/*todo: odlišit 1 a 2 */ | h1 {	/*todo: odlišit 1 a 2 */ | ||||||
| 	font-size: 200%; | 	font-size: 200%; | ||||||
|  | @ -594,6 +597,14 @@ div.org_pole, div.rocnik_pole { | ||||||
| 	text-align: center; | 	text-align: center; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | div.cislo_pole { | ||||||
|  | 	display: inline-block; | ||||||
|  | 	width: 15%; | ||||||
|  | 	min-width: 165px; | ||||||
|  | 	text-align: center; | ||||||
|  | 	padding: 10px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| div.seznam_orgu h3 { | div.seznam_orgu h3 { | ||||||
| 	text-align: center; | 	text-align: center; | ||||||
| 	margin-top: 10px; | 	margin-top: 10px; | ||||||
|  | @ -623,6 +634,11 @@ div.org_email { | ||||||
| 	height: 298px; | 	height: 298px; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #archiv-rocnik.flip-card { | ||||||
|  | 	width: 144px; | ||||||
|  | 	height: 205px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* This container is needed to position the front and back side */ | /* This container is needed to position the front and back side */ | ||||||
| .flip-card-inner { | .flip-card-inner { | ||||||
|  position: relative; |  position: relative; | ||||||
|  | @ -654,16 +670,13 @@ div.org_email { | ||||||
| div.flip-card-foto img { | div.flip-card-foto img { | ||||||
| 	width: 100%; | 	width: 100%; | ||||||
| 	height: 100%; | 	height: 100%; | ||||||
| 	filter: drop-shadow(0px 3px 3px rgba(0, 0, 0, 0.4)); /* FIXME:  obecně k obrázkům */ | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* Style the back side */ | /* Style the back side */ | ||||||
| .flip-card-back { | .flip-card-back { | ||||||
|  /*background-color: #e84e10; |  | ||||||
|  color: #fffbf6; |  | ||||||
|  background-color: #fdedd5;*/ |  | ||||||
|  background-color: #f9d59e; |  background-color: #f9d59e; | ||||||
|  color: black;/**/ |  color: black; | ||||||
|  transform: rotateY(180deg); |  transform: rotateY(180deg); | ||||||
|  padding: 10px; |  padding: 10px; | ||||||
|  padding-top: 20px; |  padding-top: 20px; | ||||||
|  | @ -678,26 +691,35 @@ div.popis_rocniku { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| div.popis_rocniku a{ | div.popis_rocniku a, div.cislo_odkazy a { | ||||||
|  | 	font-weight: bold; | ||||||
|   color: black; |   color: black; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| div.popis_rocniku a:hover{ | div.popis_rocniku a:hover, | ||||||
|  | div.cislo_odkazy a:hover { | ||||||
| 	color: #6f2509; | 	color: #6f2509; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* graf na úvodní stránce */ | div.cislo_odkazy ul { | ||||||
| 
 | 		margin: 0px; | ||||||
| a span.popup { | 		padding: 0px; | ||||||
| 	position: absolute; |  | ||||||
| 	visibility: hidden; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| a span.popup:hover { | /* archiv ročník | ||||||
| 	visibility:visible; | div.cisla-v-rocniku { | ||||||
| 	top:37px; left:37px; | 		font-weight: bold; | ||||||
|  | 		color:  #6f2509; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | div.cislo-v-rocniku-blok { | ||||||
|  | 	display: inline-block; | ||||||
|  | 	width: 150px; | ||||||
|  | 	height: 220px; | ||||||
|  | 		text-align: center; | ||||||
|  | }*/ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| /* galerie */ | /* galerie */ | ||||||
| 
 | 
 | ||||||
| /* velká fotka */ | /* velká fotka */ | ||||||
|  |  | ||||||
|  | @ -40,7 +40,7 @@ | ||||||
|           {% 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.url }}'>pdf</a>) {% endif %} |           <li><a href='{{ cislo.verejne_url }}'>{{ cislo.poradi }}. číslo</a> {% if cislo.pdf %}(<a href='{{ cislo.pdf.url }}'>pdf</a>) {% endif %} | ||||||
|           {% empty %} |           {% empty %} | ||||||
|             --- |           Žádná čísla k zobrazení | ||||||
|           {% endfor %} |           {% endfor %} | ||||||
|           </ul> |           </ul> | ||||||
|           <a href='{{ rocnik.verejne_url }}'>Výsledková listina</a> <!-- FIXME:  url výsledkovky--> |           <a href='{{ rocnik.verejne_url }}'>Výsledková listina</a> <!-- FIXME:  url výsledkovky--> | ||||||
|  |  | ||||||
|  | @ -17,14 +17,49 @@ | ||||||
|     </ul> |     </ul> | ||||||
|   {% endif %} |   {% endif %} | ||||||
| 
 | 
 | ||||||
|   <ul> | <div class="cisla-v-rocniku"> | ||||||
|   {% for c in rocnik.verejna_cisla %} |   {% for c in rocnik.verejna_cisla %} | ||||||
|   <li><a href="{{ c.verejne_url }}">Číslo {{ c.kod }}</a> |     <div class="cislo_pole"> | ||||||
|       {% if c.pdf %} | 
 | ||||||
|         (<a href='{{ c.pdf.url }}'>pdf</a>) |       <h6> Číslo {{ c.kod }}</h6> | ||||||
|       {% endif %} | 
 | ||||||
|  |       <div class="flip-card" id="archiv-rocnik"> | ||||||
|  | 
 | ||||||
|  |       <div class="flip-card-inner"> | ||||||
|  |         <div class="flip-card-front"> | ||||||
|  | 
 | ||||||
|  |       <div class="flip-card-foto"> | ||||||
|  |         {% if c.titulka_nahled %} | ||||||
|  |         <img src="{{ c.titulka_nahled.url }}" alt="{{ c.kod }}" height=180px> | ||||||
|  |         {% else %} | ||||||
|  |         <img src="" alt="no image" height=180px> | ||||||
|  |         {% endif %} | ||||||
|  |       </div> | ||||||
|  | 
 | ||||||
|  |       </div> | ||||||
|  |        <div class="flip-card-back"> | ||||||
|  | 
 | ||||||
|  |          <div class="cislo_odkazy"> | ||||||
|  |            <ul> | ||||||
|  |              <li> | ||||||
|  |                <a href="{{ c.verejne_url }}">archiv čísla</a> | ||||||
|  |              </li> | ||||||
|  |              {% if c.pdf %} | ||||||
|  |              <li> | ||||||
|  |                  <a href='{{ c.pdf.url }}'>pdf</a> | ||||||
|  |              </li> | ||||||
|  |              {% endif %} | ||||||
|  |            </ul> | ||||||
|  |          </div> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |       </div> | ||||||
|  |       </div> | ||||||
|  |       </div> | ||||||
|  |       </div> | ||||||
|  | 
 | ||||||
|   {% endfor %} |   {% endfor %} | ||||||
|   </ul> | </div> | ||||||
| 
 | 
 | ||||||
|   {% if vysledkovka %} |   {% if vysledkovka %} | ||||||
|     {% if user.is_staff %} |     {% if user.is_staff %} | ||||||
|  |  | ||||||
|  | @ -308,136 +308,16 @@ class ArchivView(generic.ListView): | ||||||
| 	def get_context_data(self, **kwargs): | 	def get_context_data(self, **kwargs): | ||||||
| 		context = super(ArchivView, self).get_context_data(**kwargs) | 		context = super(ArchivView, self).get_context_data(**kwargs) | ||||||
| 
 | 
 | ||||||
| 		vyska = 594  # px | 		cisla = Cislo.objects.filter(poradi=1) | ||||||
| 		sirka = 420  # px |  | ||||||
| 
 |  | ||||||
| 		# první číslo z každého ročníku |  | ||||||
| 		cisla = Cislo.objects.filter(poradi=1)	 |  | ||||||
| 
 |  | ||||||
| 		# op == os.path, udělá z argumentů cestu |  | ||||||
| 		png_dir = op.join(settings.MEDIA_ROOT, "cislo", "png") |  | ||||||
| 
 |  | ||||||
| 		# slovník {(ročník, url obrázku)} |  | ||||||
| 		urls ={} | 		urls ={} | ||||||
| 
 | 
 | ||||||
| 		# for j, rocnik in enumerate(Rocnik.objects.all()): | 		for i, c in enumerate(cisla): | ||||||
| 		# 	urls_rocnik = {} | 			if c.titulka_nahled: | ||||||
| 		# 	for i,c in enumerate(rocnik.cisla.all()): | 				urls[c.rocnik] = c.titulka_nahled.url | ||||||
| 		# 		if not c.pdf: | 			else: | ||||||
| 		# 			urls_rocnik[c.poradi] = op.join(settings.MEDIA_URL, "cislo", "png", "default.png") | 				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_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) |  | ||||||
| 
 | 
 | ||||||
| 		context["object_list"] = urls | 		context["object_list"] = urls | ||||||
| 
 |  | ||||||
| 		print(context) |  | ||||||
| 
 |  | ||||||
| 		# for i, c in enumerate(cisla): |  | ||||||
| 		# 	if not c.pdf: |  | ||||||
| 		# 		continue |  | ||||||
| 		# 	filename = os.path.split(c.pdf.file.name)[1].split(".")[0] |  | ||||||
| 		# 	png_filename = "{}-{}px.png".format(filename, vyska) |  | ||||||
| 
 |  | ||||||
| 		# 	# 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", |  | ||||||
| 		# 			"-rotate", str(90 * i), |  | ||||||
| 		# 			"{}[0]".format(c.pdf.path),  # titulní strana |  | ||||||
| 		# 			png_path |  | ||||||
| 		# 		]) |  | ||||||
| 
 |  | ||||||
| 		# 	urls.append( |  | ||||||
| 		# 		(op.join(settings.MEDIA_URL, "cislo", "png", png_filename), c) |  | ||||||
| 		# 	) |  | ||||||
| 		# 	vyska, sirka = sirka, vyska / 2 |  | ||||||
| 
 |  | ||||||
| 		# tags = [] |  | ||||||
| 
 |  | ||||||
| 		# def spirala(urls, tags, idx): |  | ||||||
| 		# 	"""Rekurzivně prochází urls a generuje strom elementů do tags""" |  | ||||||
| 		# 	if idx >= len(urls): |  | ||||||
| 		# 		return |  | ||||||
| 
 |  | ||||||
| 		# 	img_url, cislo = urls[idx] |  | ||||||
| 		# 	tags.append( |  | ||||||
| 		# 		"<div style='top:{}%;left:{}%;width:{}%;height:{}%;'>" |  | ||||||
| 		# 		.format( |  | ||||||
| 		# 			50 if idx % 4 == 2 else 0, |  | ||||||
| 		# 			50 if idx % 4 == 1 else 0, |  | ||||||
| 		# 			50 if idx % 2 == 1 else 100, |  | ||||||
| 		# 			50 if idx > 0 and idx % 2 == 0 else 100 |  | ||||||
| 		# 		) |  | ||||||
| 		# 	) |  | ||||||
| 		# 	tags.append("<a href='{}' title='{}'>".format( |  | ||||||
| 		# 		cislo.verejne_url(), cislo.kod() |  | ||||||
| 		# 	)) |  | ||||||
| 		# 	tags.append( |  | ||||||
| 		# 		"<img src='{}' style='top:{}%;left:{}%;width:{}%;height:{}%;'>" |  | ||||||
| 		# 		.format( |  | ||||||
| 		# 			img_url, |  | ||||||
| 		# 			50 if idx % 4 == 3 else 0, |  | ||||||
| 		# 			50 if idx % 4 == 2 else 0, |  | ||||||
| 		# 			50 if idx % 2 == 0 else 100, |  | ||||||
| 		# 			50 if idx % 2 == 1 else 100 |  | ||||||
| 		# 		) |  | ||||||
| 		# 	) |  | ||||||
| 		# 	tags.append("</a>") |  | ||||||
| 		# 	spirala(urls, tags, idx + 1) |  | ||||||
| 		# 	tags.append("</div>") |  | ||||||
| 		# spirala(urls, tags, 0) |  | ||||||
| 
 |  | ||||||
| 		# context["nahledy"] = "\n".join(tags) |  | ||||||
| 		 | 		 | ||||||
| 		return context | 		return context | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Pavel 'LEdoian' Turinsky
						Pavel 'LEdoian' Turinsky