galerie | Pripisovani komentaru
Pokud je galerie neverejna, pak organizatori mohou pripisovat komentare
This commit is contained in:
parent
44903958dc
commit
51a4e90162
4 changed files with 30 additions and 1 deletions
|
@ -9,3 +9,4 @@
|
|||
* hromadne nahravani fotek
|
||||
* psani komentaru
|
||||
* do CSS
|
||||
* znovuukladani malych a strednich fotek -- spravit, aby se tak nedělo furt
|
||||
|
|
6
galerie/forms.py
Normal file
6
galerie/forms.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
#coding: utf-8
|
||||
|
||||
from django import forms
|
||||
|
||||
class KomentarForm(forms.Form):
|
||||
komentar = forms.CharField(label = "Komentář:", max_length = 300, required=False)
|
|
@ -35,8 +35,18 @@
|
|||
{% endwith %}
|
||||
{% endif%}
|
||||
</div>
|
||||
|
||||
{# Popisek fotky #}
|
||||
<div class="popis">
|
||||
{{obrazek.popis}}
|
||||
{% if preview %}
|
||||
<form action=".#obsah" method="post">
|
||||
{% csrf_token %}
|
||||
{{form}}
|
||||
<input name="odeslat" type="submit" value="Změň komentář">
|
||||
</form>
|
||||
{% else %}
|
||||
{{obrazek.popis}}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="galerie_bot">
|
||||
|
|
|
@ -8,6 +8,8 @@ from django.template import RequestContext
|
|||
from galerie.models import Obrazek, Galerie
|
||||
from seminar.models import Soustredeni
|
||||
|
||||
from galerie.forms import KomentarForm
|
||||
|
||||
|
||||
#def index(request, stitek=None):
|
||||
#if stitek == None:
|
||||
|
@ -59,6 +61,15 @@ def detail(request, pk, fotka, soustredeni):
|
|||
obrazek = get_object_or_404(Obrazek, pk=fotka)
|
||||
obrazky = galerie.obrazek_set.all()
|
||||
|
||||
# vytvoreni a obslouzeni formulare
|
||||
if request.method == 'POST':
|
||||
form = KomentarForm(request.POST)
|
||||
if form.is_valid():
|
||||
obrazek.popis = form.cleaned_data['komentar']
|
||||
obrazek.save()
|
||||
else:
|
||||
form = KomentarForm({'komentar': obrazek.popis})
|
||||
|
||||
# Poradi aktualniho obrazku v galerii/stitku.
|
||||
for i in range(len(obrazky)):
|
||||
if obrazky[i] == obrazek:
|
||||
|
@ -93,5 +104,6 @@ def detail(request, pk, fotka, soustredeni):
|
|||
'obrazky_predchozi' : obrazky_predchozi,
|
||||
'obrazky_dalsi' : obrazky_dalsi,
|
||||
'preview' : preview,
|
||||
'form' : form,
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue