|
|
@ -5,9 +5,10 @@ import random |
|
|
|
from django.http import HttpResponse, Http404 |
|
|
|
from django.shortcuts import render, HttpResponseRedirect, get_object_or_404 |
|
|
|
from django.template import RequestContext |
|
|
|
from datetime import datetime |
|
|
|
|
|
|
|
from galerie.models import Obrazek, Galerie |
|
|
|
from seminar.models import Soustredeni |
|
|
|
|
|
|
|
from galerie.forms import KomentarForm, NewGalerieForm |
|
|
|
|
|
|
|
|
|
|
@ -110,20 +111,47 @@ def detail(request, pk, fotka, soustredeni): |
|
|
|
|
|
|
|
def new_galerie(request, galerie, soustredeni): |
|
|
|
|
|
|
|
# zjistime k jakemu soustredeni se vaze nove vytvarena galerie |
|
|
|
soustredeni = get_object_or_404(Soustredeni, pk = soustredeni) |
|
|
|
# pokud je parametr galerie 0, pak jde o hlavni galerii |
|
|
|
# kdyz je nejaky jiny, pak je pk galerie pod kterou tu dalsi vytvarim |
|
|
|
if int(galerie) == 0: |
|
|
|
galerie_up = False |
|
|
|
galerie_text = "Hlavní fotogalerie soustředění" |
|
|
|
else: |
|
|
|
galerie = get_object_or_404(Galerie, pk = int(galerie)) |
|
|
|
galerie_text = "podgalerii ke galerii " + str(galerie) |
|
|
|
galerie_up = get_object_or_404(Galerie, pk = int(galerie)) |
|
|
|
galerie_text = "podgalerii ke galerii " + str(galerie_up) |
|
|
|
|
|
|
|
# obsluha formulare umoznujiciho multiple nahravani fotek |
|
|
|
if request.method == 'POST': |
|
|
|
form = NewGalerieForm(request.POST, request.FILES) |
|
|
|
if form.is_valid(): |
|
|
|
# TODO dopsat vytvoreni fotogalerie |
|
|
|
# vytvoreni nove galerie |
|
|
|
gal = Galerie() |
|
|
|
gal.nazev = form.cleaned_data['nazev'] |
|
|
|
gal.popis = form.cleaned_data['popis'] |
|
|
|
gal.zobrazit = 1 # galerie je v procesu vytvareni |
|
|
|
''' pokud je to podgalerie pridej nadrazenou galerii |
|
|
|
a nadrazene soustredeni nechej volne, |
|
|
|
pokud je to hlavni galerie, tak nadrazena galerie neexistuje, |
|
|
|
ale v takovem pripade musi byt nadrazene soustredeni a ne jinak ''' |
|
|
|
if galerie_up: |
|
|
|
gal.galerie_up = galerie_up |
|
|
|
else: |
|
|
|
gal.soustredeni = soustredeni |
|
|
|
gal.save() |
|
|
|
|
|
|
|
# zpracovani obrazku v galerii |
|
|
|
for obr in request.FILES.getlist('obr'): |
|
|
|
pass # TODO dopsat ulozeni obrazku |
|
|
|
# TODO presmerovani na nove vytvořenou galerii |
|
|
|
o = Obrazek() |
|
|
|
o.obrazek_velky = obr |
|
|
|
o.nazev = str(gal) + "/" + str(obr) |
|
|
|
o.datum = datetime.now() #TODO vycist z EXIFU |
|
|
|
o.galerie = gal |
|
|
|
o.save() |
|
|
|
|
|
|
|
# presmerovani na prave vzniklou galerii |
|
|
|
return HttpResponseRedirect('../../' + str(gal.pk)) |
|
|
|
|
|
|
|
else: |
|
|
|
form = NewGalerieForm() |
|
|
|