Merge branch 'matej-galerie'
This commit is contained in:
		
						commit
						a2c24c5a63
					
				
					 6 changed files with 268 additions and 68 deletions
				
			
		|  | @ -104,7 +104,7 @@ class Obrazek(models.Model): | |||
|                               datum_int[3], datum_int[4], datum_int[5]) | ||||
|     jmeno = os.path.basename(self.obrazek_velky.file.name) | ||||
|     if not self.obrazek_stredni: | ||||
|       Obrazek._vyrobMiniaturu(original, jmeno, 600, self.obrazek_stredni) | ||||
|       Obrazek._vyrobMiniaturu(original, jmeno, 1024, self.obrazek_stredni) | ||||
|     if not self.obrazek_maly: | ||||
|       Obrazek._vyrobMiniaturu(original, jmeno, 200, self.obrazek_maly) | ||||
|     super(Obrazek, self).save() | ||||
|  |  | |||
|  | @ -1,13 +1,48 @@ | |||
| {% extends "galerie/Base.html" %} | ||||
| 
 | ||||
| {% block title %}{% block nadpis1a %} | ||||
| {{galerie.nazev}} | Galerie | ||||
| {% endblock %}{% endblock %} | ||||
| 
 | ||||
| {% block nadpis1a %} | ||||
| {{galerie.nazev}}: {{ obrazek.popis | default:"Fotka" }} | ||||
| {% endblock %} | ||||
| 
 | ||||
| {% block script %} | ||||
|   {% with obrazky_predchozi|last as predchozi_obrazek %} | ||||
|   {% with obrazky_dalsi|first as dalsi_obrazek %} | ||||
|       <script type="text/javascript"> | ||||
|           $(document).keydown(function(e) { | ||||
|               {% if predchozi_obrazek %} | ||||
|                   // doleva | ||||
|                   if (e.which == 37) { | ||||
|                       window.location.assign("../{{ predchozi_obrazek.pk }}#nahoru"); | ||||
|                   } | ||||
|               {% endif %} | ||||
|               {% if dalsi_obrazek %} | ||||
|                   // doprava | ||||
|                   if (e.which == 39) { | ||||
|                       window.location.assign("../{{ dalsi_obrazek.pk }}#nahoru"); | ||||
|                   } | ||||
|               {% endif %} | ||||
|               if (e.which == 27) { | ||||
|                   window.location.assign("../#obsah") | ||||
|               } | ||||
|           }) | ||||
|       </script> | ||||
|   {% endwith %} | ||||
|   {% endwith %} | ||||
| {% endblock %} | ||||
| 
 | ||||
| {% block content %} | ||||
|   <div id="popis"> | ||||
|     <h2><a title="Zpět na náhled fotek" href="../#obsah">{{galerie.nazev}}</a></h2> | ||||
|   </div> | ||||
| 
 | ||||
| 
 | ||||
|   <h2> | ||||
|     {% for g in cesta %} | ||||
|         <a href="../../{{ g.pk }}">{{ g.nazev }}</a> > | ||||
|     {% endfor %} | ||||
|     {{ obrazek.nazev }} | ||||
|   </h2> | ||||
|   <!--<div id="nahoru">--> | ||||
|   <!--<a title="Zpět do galerie" href="../#obsah">Zpět na: {{galerie.nazev}}</a>--> | ||||
|   <!--</div>--> | ||||
| 
 | ||||
| 
 | ||||
|   {# TODO šipky na přecházeni dodelat ve stylech #} | ||||
|  | @ -15,28 +50,32 @@ | |||
|     {% if obrazky_predchozi %} | ||||
|       {% with obrazky_predchozi|last as predchozi_obrazek %} | ||||
|         <div> | ||||
|           <a title="Předchozí" class="predchozi_obrazek" href="../{{predchozi_obrazek.pk}}#popis"></a> | ||||
|           <a title="Předchozí" class="predchozi_obrazek" href="../{{predchozi_obrazek.pk}}#nahoru"></a> | ||||
|         </div> | ||||
|       {% endwith %} | ||||
|     {% endif%} | ||||
|     <img src={{obrazek.obrazek_stredni.url}} | ||||
|     <img src="{{obrazek.obrazek_stredni.url}}" | ||||
|          height="{{vyska}}" | ||||
|          width="{{sirka}}" | ||||
|          alt="{{obrazek.popis}}" | ||||
|          class="obrazek"> | ||||
|          class="obrazek" id="nahoru"> | ||||
|           | ||||
|     {% if obrazky_dalsi %} | ||||
|       {% with obrazky_dalsi|first as dalsi_obrazek %} | ||||
|         <div> | ||||
|           <a title="Další" class="dalsi_obrazek" href="../{{dalsi_obrazek.pk}}#popis"></a> | ||||
|           <a title="Další" class="dalsi_obrazek" href="../{{dalsi_obrazek.pk}}#nahoru"></a> | ||||
|         </div> | ||||
|       {% endwith %} | ||||
|     {% endif%} | ||||
|   </div> | ||||
|   <!--<div>--> | ||||
|   <!--<a href="{{ obrazek.obrazek_velky.url }}">Obrázek v plné velikosti</a>--> | ||||
|   <!--</div>--> | ||||
| 
 | ||||
|   {# Popisek fotky #} | ||||
|   <div class="popis"> | ||||
|     {% if preview %} | ||||
|     <form action=".#popis" method="post"> | ||||
|     {% if not preview %} | ||||
|     <form action=".#nahoru" method="post"> | ||||
|       {% csrf_token %} | ||||
|       <table> | ||||
|         <tr><td><label>Aktuální komentář:</label></td><td>{{obrazek.popis}}</td> | ||||
|  | @ -60,7 +99,7 @@ | |||
|     {% endif %} | ||||
|     {# nahledy predchozich obrazku #} | ||||
|     {% for obrazek in obrazky_predchozi %} | ||||
|     <a href="../{{obrazek.pk}}#popis"><img src="{{obrazek.obrazek_maly.url}}" height="100"></a> | ||||
|     <a href="../{{obrazek.pk}}#nahoru"><img src="{{obrazek.obrazek_maly.url}}" height="100"></a> | ||||
|     {% endfor %} | ||||
|     {# nahled aktualniho obrazku -- TODO po kliknuti vypsat: Prohrál jsi #} | ||||
|     <img src={{obrazek.obrazek_maly.url}} | ||||
|  | @ -70,7 +109,7 @@ | |||
|          class="obrazek"> | ||||
|     {# nahledy nasledujicich obrazku #} | ||||
|     {% for obrazek in obrazky_dalsi %} | ||||
|     <a href="../{{obrazek.pk}}#popis"><img src="{{obrazek.obrazek_maly.url}}" height="100"></a> | ||||
|     <a href="../{{obrazek.pk}}#nahoru"><img src="{{obrazek.obrazek_maly.url}}" height="100"></a> | ||||
|     {% endfor %} | ||||
|     {# odkaz na nasledujici galerii #} | ||||
|     {% if nasledujici_galerie %} | ||||
|  |  | |||
|  | @ -1,35 +1,76 @@ | |||
| {% extends "galerie/Base.html" %} | ||||
| 
 | ||||
| {% block title %}{% block nadpis1a %} | ||||
| {{galerie.nazev}} | Galerie TODO title | ||||
| {% endblock %}{% endblock %} | ||||
| {% block nadpis1a %} | ||||
| Galerie {{galerie.nazev}} | ||||
| {% endblock %} | ||||
| 
 | ||||
| {% block content %} | ||||
|   <h2>{{galerie.nazev}}</h2> | ||||
| 
 | ||||
|   <h2> | ||||
|     {% for g in cesta %} | ||||
|       {% if not forloop.last %} | ||||
|         <a href="../{{ g.pk }}">{{ g.nazev }}</a> > | ||||
|       {% else %} | ||||
|         {{ g.nazev }} | ||||
|       {% endif %} | ||||
|     {% endfor %} | ||||
|   </h2> | ||||
| 
 | ||||
|   {% if not obrazky %} | ||||
|    <div class="galerie_hlavicka"> | ||||
|     {% if galerie.titulni_obrazek %} | ||||
|       <img src="{{ galerie.titulni_obrazek.obrazek_stredni.url }}" style="border: 1px solid black;"> | ||||
|     {% endif %} | ||||
|     {% if galerie.popis %} | ||||
|       <div class="popis"> | ||||
|         {{ galerie.popis }} | ||||
|       </div> | ||||
|     {% endif %} | ||||
|    </div> | ||||
|   {% endif %} | ||||
| 
 | ||||
|   {# podgalerie #} | ||||
|   {% if podgalerie or galerie.galerie_up %} | ||||
|     <h3> PODGALERIE </h3> | ||||
|     <ul> | ||||
|     {% if galerie.galerie_up %} | ||||
|       <li><a href="../{{galerie.galerie_up.pk}}">..</a> | ||||
|     {% endif %} | ||||
|     {% for galerie in podgalerie %} | ||||
|       {% if galerie.zobrazit < 1 or user.is_staff %} | ||||
|       <li><a href="../{{galerie.pk}}">{{galerie}}</a> | ||||
|         {% if user.is_staff and galerie.zobrazit > 0 %} | ||||
|           ({{galerie.poradi}}) | ||||
|           <span class="plus"><a href="plus/{{galerie.pk}}/">+</a></span> | ||||
|           <span class="minus"><a href="minus/{{galerie.pk}}/">-</a></span> | ||||
|         {% endif %} | ||||
| 
 | ||||
|     {% if sourozenci|length > 1 %} | ||||
|       {% for g in sourozenci %} | ||||
|         {% if g.pk != galerie.pk %} | ||||
|           <a href="../{{ g.pk }}">{{ g.nazev }}</a> | ||||
|         {% else %} | ||||
|           {{ g.nazev }} | ||||
|         {% endif %} | ||||
|         <span style="width: 1em; display: inline-block;"></span> | ||||
|       {% endfor %} | ||||
|   </ul> | ||||
|     {% endif %} | ||||
| 
 | ||||
|     {% if podgalerie %} | ||||
|       <div class="galerie_nahledy"> | ||||
|       {% for galerie in podgalerie %} | ||||
|         <div class="podgalerie_nahled"> | ||||
|           {% if galerie.zobrazit < 1 or user.is_staff %} | ||||
|             {% with galerie.titulni_obrazek.obrazek_maly as obrazek %} | ||||
|             <a href="../{{galerie.pk}}"><img src="{{ obrazek.url }}" | ||||
|               width={% widthratio obrazek.width 200 167 %} | ||||
|               height={% widthratio obrazek.height 200 167 %} /></a> | ||||
|             {% endwith %} | ||||
|            <div> | ||||
|               <a href="../{{ galerie.pk }}">{{ galerie }}</a> | ||||
|            </div> | ||||
|          {#  {% if user.is_staff and galerie.zobrazit > 0 %} #} | ||||
|          {#    ({{galerie.poradi}}) #} | ||||
|          {#    <span class="plus"><a href="plus/{{galerie.pk}}/">+</a></span> #} | ||||
|          {#    <span class="minus"><a href="minus/{{galerie.pk}}/">-</a></span> #} | ||||
|          {#  {% endif %} #} | ||||
|           {% endif %} | ||||
|         </div> | ||||
|       {% endfor %} | ||||
|       </div> | ||||
|     {% endif %} | ||||
|   {% endif %} | ||||
|   {% if user.is_staff and galerie.zobrazit > 0 %} | ||||
|   <ul> | ||||
|     <li><a href="./new">VYTVOŘIT NOVOU PODGALERII </a> | ||||
|   </ul> | ||||
|   <div class="mam-org-only"> | ||||
|       <a href="./new">Vytvořit novou podgalerii </a> | ||||
|   </div> | ||||
|   {% endif %} | ||||
| 
 | ||||
|   {# obrazky v galerii #} | ||||
|  | @ -38,7 +79,7 @@ | |||
|     {% for obrazek in obrazky %} | ||||
|         <div class="galerie_nahled"> | ||||
|           <span class="vystredeno"></span> | ||||
|           <a title="Zobrazit tuto fotografii" href="./{{obrazek.pk}}#popis"> | ||||
|           <a title="Zobrazit tuto fotografii" href="./{{obrazek.pk}}#nahoru"> | ||||
|           <img | ||||
|             src="{{obrazek.obrazek_maly.url}}" | ||||
|             width={% widthratio obrazek.obrazek_maly.width 200 167 %} | ||||
|  | @ -48,9 +89,25 @@ | |||
|     {% endfor %} | ||||
|     <br> | ||||
|   </div> | ||||
| 
 | ||||
|   <div class="galerie_predchozi_nasledujici"> | ||||
|     {% if predchozi %} | ||||
|       <div class="predchozi"> | ||||
|         <a href="../{{ predchozi.pk }}">Předchozí: {{ predchozi.nazev }}</a> | ||||
|       </div> | ||||
|     {% endif %} | ||||
|     {% if nasledujici %} | ||||
|       <div class="nasledujici"> | ||||
|         <a href="../{{ nasledujici.pk }}">Následující: {{ nasledujici.nazev }}</a> | ||||
|       </div> | ||||
|     {% endif %} | ||||
|   </div> | ||||
| 
 | ||||
|   {% else %} | ||||
|     {% if not podgalerie %} | ||||
|       <div class="zadne-vysledky"> | ||||
|         V galerii nejsou žádné fotky. | ||||
|       </div> | ||||
|     {% endif %} | ||||
|   {% endif %} | ||||
| {% endblock content %} | ||||
|  |  | |||
|  | @ -20,23 +20,55 @@ def zobrazit(galerie, request): | |||
|             raise Http404 | ||||
|     return preview | ||||
| 
 | ||||
| 
 | ||||
| def cesta_od_korene(g): | ||||
|     """Vrátí seznam galerií od kořene ke g""" | ||||
|     cesta = [] | ||||
|     while g != None: | ||||
|         cesta.append(g) | ||||
|         g = g.galerie_up | ||||
|     return reversed(cesta) | ||||
| 
 | ||||
| 
 | ||||
| def nahled(request, pk, soustredeni): | ||||
|     """Zobrazeni nahledu vsech fotek ve skupine.""" | ||||
|     galerie = get_object_or_404(Galerie, pk=pk) | ||||
|     podgalerie = Galerie.objects.filter(galerie_up = galerie).order_by('poradi') | ||||
|     obrazky = Obrazek.objects.filter(galerie = galerie).order_by('datum') | ||||
|     preview = zobrazit(galerie, request) | ||||
| 
 | ||||
|     sourozenci = [] | ||||
|     if galerie.galerie_up: | ||||
|         sourozenci = galerie.galerie_up.galerie_set.all().order_by('poradi') | ||||
| 
 | ||||
|     predchozi = None | ||||
|     nasledujici = None | ||||
|     minuly = None | ||||
|     for g in sourozenci: | ||||
|         if g.pk == galerie.pk: | ||||
|             predchozi = minuly | ||||
|         if minuly != None and minuly.pk == galerie.pk: | ||||
|             nasledujici = g | ||||
|             break | ||||
|         minuly = g | ||||
| 
 | ||||
|     cesta = cesta_od_korene(galerie) | ||||
| 
 | ||||
|     return render(request, 'galerie/GalerieNahled.html', | ||||
|         {'galerie' : galerie, | ||||
|          'podgalerie' : podgalerie, | ||||
|          'obrazky' : obrazky, | ||||
|          'preview' : preview, | ||||
|          'cesta': cesta, | ||||
|          'sourozenci': sourozenci, | ||||
|          'predchozi': predchozi, | ||||
|          'nasledujici': nasledujici, | ||||
|         }) | ||||
| 
 | ||||
| def detail(request, pk, fotka, soustredeni): | ||||
|   """Zobrazeni nahledu fotky s id 'fotka'.""" | ||||
|   MAX_VYSKA = 600 | ||||
|   MAX_SIRKA = 600 | ||||
|   MAX_VYSKA = 900 | ||||
|   MAX_SIRKA = 900 | ||||
|   MAX_VYSKA_MALA = 100 | ||||
|   MAX_SIRKA_MALA = 200 | ||||
|   NAHLEDU = 1 | ||||
|  | @ -115,6 +147,7 @@ def detail(request, pk, fotka, soustredeni): | |||
|        'obrazky_dalsi' : obrazky_dalsi, | ||||
|        'preview' : preview, | ||||
|        'form' : form, | ||||
|        'cesta': cesta_od_korene(galerie), | ||||
|       }) | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -15,6 +15,7 @@ body { | |||
|   background: #fff0d7; | ||||
|   padding: 10px;  | ||||
|   margin: 10px -10px;  | ||||
|   border: orange 2px dashed; | ||||
| } | ||||
| 
 | ||||
| table .border-r { | ||||
|  | @ -150,6 +151,10 @@ div.menu li.selected a { | |||
| 	z-index: 15px; | ||||
| } | ||||
| 
 | ||||
| h2 a:hover { | ||||
|     text-decoration: none; | ||||
| } | ||||
| 
 | ||||
| #submenu { | ||||
| 	position: relative; | ||||
| 	top: -15px; | ||||
|  | @ -467,26 +472,35 @@ div.zadani_azad_termin { | |||
|   background-repeat: no-repeat; | ||||
| } | ||||
| 
 | ||||
| .galerie{ | ||||
| .galerie { | ||||
|   position: relative; | ||||
|   text-align: center; | ||||
|   width: 630px; | ||||
|   margin: 0 auto 0 auto; | ||||
|   /*width: 100%;*/ | ||||
|   margin: 20px auto 0 auto; | ||||
| } | ||||
| 
 | ||||
| .galerie h2{ | ||||
| .galerie h2 { | ||||
|   text-align: center; | ||||
| } | ||||
| 
 | ||||
| .popis{ | ||||
| .galerie_hlavicka { | ||||
|     margin: 30px auto 30px auto; | ||||
| } | ||||
| 
 | ||||
| .popis { | ||||
|   margin: 10px 10px 30px 0px; | ||||
|   clear: all; | ||||
| } | ||||
| 
 | ||||
| #nahoru { | ||||
|   text-align: center; | ||||
|   margin: 10px 10px 30px 10px; | ||||
| } | ||||
| 
 | ||||
| .galerie_nahledy{ | ||||
|   /*margin: 1em 0;*/ | ||||
|   margin: 0 auto 0 auto; | ||||
|   margin: 0 auto 30px auto; | ||||
|   text-align: center; | ||||
|   overflow: auto; | ||||
| } | ||||
| 
 | ||||
| .galerie_nahledy img{ | ||||
|  | @ -499,17 +513,21 @@ div.zadani_azad_termin { | |||
| } | ||||
| 
 | ||||
| .galerie_nahled{ /* frame */ | ||||
|   display: inline-block; | ||||
|   position: relative; | ||||
|   float: left; | ||||
|   width: 190px; | ||||
|   height: 190px; | ||||
|   width: 200px; | ||||
|   height: 200px; | ||||
|   text-align: center; | ||||
|   border: solid; | ||||
|   border-width: 2px; | ||||
|   border-radius: 5px; | ||||
|   border-color: #ffa500; | ||||
|   background-color: #ffb52d; | ||||
|   /*border-color: #ffa500;*/ | ||||
|   border-color: #ffd546; | ||||
|   /*background-color: #ffb52d;*/ | ||||
|   background-color: white; | ||||
|   white-space: nowrap; | ||||
|   margin: 10px; | ||||
|   margin: 10px 20px 10px 0px; | ||||
| } | ||||
| 
 | ||||
| .vystredeno{ /* helper */ | ||||
|  | @ -518,11 +536,61 @@ div.zadani_azad_termin { | |||
|   vertical-align: middle; | ||||
| } | ||||
| 
 | ||||
| .galerie_nahled img{ | ||||
|   border-radius: 2px; | ||||
| .galerie_nahled img { | ||||
|   vertical-align: middle; | ||||
|   max-height: 180px; | ||||
|   max-width: 180px; | ||||
|   /*border: 1px solid white;*/ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| .galerie_nahled img:hover { | ||||
|     /*border: 1px solid #ffa500;*/ | ||||
| } | ||||
| 
 | ||||
| .galerie_nahled div { | ||||
|     position: absolute; | ||||
|     bottom: 0px; | ||||
|     width: 100%; | ||||
|     text-align: center; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| .podgalerie_nahled { | ||||
|   position: relative; | ||||
|   float: left; | ||||
|   width: 200px; | ||||
|   height: 200px; | ||||
|   text-align: center; | ||||
|   border: solid; | ||||
|   border-width: 2px; | ||||
|   border-radius: 5px; | ||||
|   border-color: #ffa500; | ||||
|   /*border-color: #ffd546;*/ | ||||
|   background-color: #ffd546; | ||||
|   /*background-color: white;*/ | ||||
|   white-space: nowrap; | ||||
|   margin: 10px 20px 10px 0px; | ||||
| } | ||||
| 
 | ||||
| .podgalerie_nahled img { | ||||
|     margin-top: 20px; | ||||
|     margin-bottom: 15px; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /* Odkazy na předchozí a následující podgalerii */ | ||||
| .galerie_predchozi_nasledujici { | ||||
|     overflow: auto; | ||||
|     margin: 10px auto 10px auto; | ||||
| } | ||||
| 
 | ||||
| .galerie_predchozi_nasledujici .predchozi { | ||||
|     float: left; | ||||
| } | ||||
| 
 | ||||
| .galerie_predchozi_nasledujici .nasledujici { | ||||
|     float: right; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -29,6 +29,9 @@ | |||
|       src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> | ||||
|     </script> | ||||
| 
 | ||||
|     {# script specifický pro stránku #} | ||||
|     {% block script %}{% endblock %} | ||||
| 
 | ||||
|   </head> | ||||
|   <body class='{% if user.is_staff %}org-logged-in{% endif %}'> | ||||
|   {% if user.is_staff %} | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Matěj Kocián
						Matěj Kocián