Bc. Petr Pecha
9 years ago
5 changed files with 177 additions and 2 deletions
@ -0,0 +1,2 @@ |
|||||
|
images |
||||
|
lightbox |
@ -0,0 +1,72 @@ |
|||||
|
{% extends "base.html" %} |
||||
|
|
||||
|
{% block title %}{% block nadpis1a %} |
||||
|
{{galerie.nazev}} | Galerie TODO title |
||||
|
{% endblock %}{% endblock %} |
||||
|
|
||||
|
{# TODO predelat pres context processor #} |
||||
|
{% block header %}soustredeni{% endblock %} |
||||
|
{% block menu_soustredeni %}selected{% endblock %} |
||||
|
{% block submenu %}{% include 'seminar/soustredeni/submenu.html' %}{% endblock %} |
||||
|
|
||||
|
{% block content %} |
||||
|
<h2>{{galerie.nazev}}</h2> |
||||
|
|
||||
|
{# podgalerie #} |
||||
|
{% if galerie.galerie_set.all or galerie.galerie_up %} |
||||
|
<h3> PODGALERIE </h3> |
||||
|
<ul> |
||||
|
{% if galerie.galerie_up %} |
||||
|
<li><a href="../{{galerie.galerie_up.pk}}">..</a> |
||||
|
{% endif %} |
||||
|
{% for galerie in galerie.galerie_set.all %} |
||||
|
{% if galerie.zobrazit < 1 or user.is_staff %} |
||||
|
<li><a href="../{{galerie.pk}}">{{galerie}}</a> |
||||
|
{% endif %} |
||||
|
{% endfor %} |
||||
|
</ul> |
||||
|
{% endif %} |
||||
|
|
||||
|
{# obrazky v galerii #} |
||||
|
{% if galerie.obrazek_set.all %} |
||||
|
<table class="galerie_nahled"> |
||||
|
{% for obrazek in galerie.obrazek_set.all %} |
||||
|
{% if forloop.counter|add:-1|divisibleby:3 %} |
||||
|
<tr> |
||||
|
{% endif %} |
||||
|
<td class="vystredeno"> |
||||
|
<a title="Zobrazit tuto fotografii" href="./{{obrazek.pk}}#obsah" |
||||
|
class="jednoducha-galerie"> |
||||
|
<img |
||||
|
src="{{obrazek.obrazek_maly.url}}" |
||||
|
width={% widthratio obrazek.obrazek_maly.width 200 167 %} |
||||
|
height={% widthratio obrazek.obrazek_maly.height 200 167 %} /> |
||||
|
</a> |
||||
|
<!--<a href="{{obrazek.obrazek_velky.url}}" |
||||
|
class="javascript-galerie" data-lightbox="galerie" data-title="{{obrazek.popis}}" |
||||
|
style="display: none;"> |
||||
|
<img |
||||
|
src="{{obrazek.obrazek_maly.url}}" |
||||
|
width={% widthratio obrazek.obrazek_maly.width 200 167 %} |
||||
|
height={% widthratio obrazek.obrazek_maly.height 200 167 %} /> |
||||
|
</a>--> |
||||
|
</td> |
||||
|
{% if forloop.last %} |
||||
|
{% if not forloop.counter|divisibleby:3 %} |
||||
|
<td></td> |
||||
|
{% endif %} |
||||
|
{% if not forloop.counter|divisibleby:2 %} |
||||
|
<td></td> |
||||
|
{% endif %} |
||||
|
{% endif %} |
||||
|
{% if forloop.counter|divisibleby:3 or forloop.last %} |
||||
|
</tr> |
||||
|
{% endif %} |
||||
|
{% endfor %} |
||||
|
</table> |
||||
|
{% else %} |
||||
|
<div class="zadne-vysledky"> |
||||
|
V galerii nejsou žádné fotky. |
||||
|
</div> |
||||
|
{% endif %} |
||||
|
{% endblock content %} |
@ -0,0 +1,98 @@ |
|||||
|
# coding: utf-8 |
||||
|
|
||||
|
import random |
||||
|
|
||||
|
from django.http import HttpResponse, Http404 |
||||
|
from django.shortcuts import render, HttpResponseRedirect, get_object_or_404 |
||||
|
from django.template import RequestContext |
||||
|
from galerie.models import Obrazek, Galerie |
||||
|
from seminar.models import Soustredeni |
||||
|
|
||||
|
|
||||
|
#def index(request, stitek=None): |
||||
|
#if stitek == None: |
||||
|
#return HttpResponseRedirect('./0/') |
||||
|
# |
||||
|
#galerie = Galerie.publikovane_galerie() |
||||
|
#if int(stitek) != 0: |
||||
|
#galerie = galerie.filter(stitek = stitek) |
||||
|
#if not galerie: |
||||
|
#raise Http404 |
||||
|
#galerie = galerie.order_by("-datum_zmeny") |
||||
|
# |
||||
|
#return render(request, 'Galerie/GalerieIndex.html', |
||||
|
#{'galerie' : galerie, |
||||
|
#'stitky' : Stitek.stitky_u_galerii(), |
||||
|
#'umisteni_stitek' : stitek, |
||||
|
#'umisteni_Fotogalerie' : True, |
||||
|
#}) |
||||
|
|
||||
|
def nahled(request, pk, soustredeni): |
||||
|
"""Zobrazeni nahledu vsech fotek ve skupine.""" |
||||
|
galerie = get_object_or_404(Galerie, pk=pk) |
||||
|
preview = False |
||||
|
if galerie.zobrazit >= 1: |
||||
|
if request.user.is_staff: |
||||
|
preview = True; |
||||
|
else: |
||||
|
raise Http404 |
||||
|
return render(request, 'galerie/GalerieNahled.html', |
||||
|
{'galerie' : galerie, |
||||
|
'preview' : preview, |
||||
|
}) |
||||
|
|
||||
|
def detail(request, pk, fotka): |
||||
|
"""Zobrazeni nahledu fotky s id 'fotka'.""" |
||||
|
MAX_VYSKA = 600 |
||||
|
MAX_SIRKA = 600 |
||||
|
MAX_VYSKA_MALA = 100 |
||||
|
MAX_SIRKA_MALA = 200 |
||||
|
NAHLEDU = 3 |
||||
|
|
||||
|
galerie = get_object_or_404(Galerie, pk=pk) |
||||
|
preview = False |
||||
|
if not galerie.je_publikovano(): |
||||
|
if request.user.is_authenticated(): |
||||
|
preview = True; |
||||
|
else: |
||||
|
raise Http404 |
||||
|
obrazek = get_object_or_404(Obrazek, pk=fotka) |
||||
|
obrazky = galerie.obrazky.all() |
||||
|
|
||||
|
# Poradi aktualniho obrazku v galerii/stitku. |
||||
|
for i in range(len(obrazky)): |
||||
|
if obrazky[i] == obrazek: |
||||
|
znacka = i |
||||
|
break |
||||
|
else: |
||||
|
# Obrazek neni v galerii/stitku. |
||||
|
raise Http404 |
||||
|
|
||||
|
# Nacteni okolnich obrazku. |
||||
|
obrazky_dalsi = obrazky[znacka+1:znacka+NAHLEDU+1] |
||||
|
if znacka > NAHLEDU: |
||||
|
obrazky_predchozi = obrazky[znacka-NAHLEDU:znacka] |
||||
|
else: |
||||
|
obrazky_predchozi = obrazky[0:znacka] |
||||
|
|
||||
|
# Preskalovani obrazku do vybraneho prostoru. |
||||
|
vyska = obrazek.obrazek_stredni.height |
||||
|
sirka = obrazek.obrazek_stredni.width |
||||
|
if vyska > MAX_VYSKA: |
||||
|
sirka = sirka * MAX_VYSKA / vyska |
||||
|
vyska = MAX_VYSKA |
||||
|
if sirka > MAX_SIRKA: |
||||
|
vyska = vyska * MAX_SIRKA / sirka |
||||
|
sirka = MAX_SIRKA |
||||
|
|
||||
|
return render(request, 'Galerie/Galerie.html', |
||||
|
{'galerie' : galerie, |
||||
|
'obrazek' : obrazek, |
||||
|
'vyska' : vyska, |
||||
|
'sirka' : sirka, |
||||
|
'obrazky_predchozi' : obrazky_predchozi, |
||||
|
'obrazky_dalsi' : obrazky_dalsi, |
||||
|
'preview' : preview, |
||||
|
'umisteni_Fotogalerie' : True, |
||||
|
}) |
||||
|
|
Loading…
Reference in new issue