Merge branch 'test'
Opravy galerie
This commit is contained in:
commit
b7ceef2747
3 changed files with 32 additions and 8 deletions
20
galerie/migrations/0008_auto_20191209_2326.py
Normal file
20
galerie/migrations/0008_auto_20191209_2326.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.26 on 2019-12-09 22:26
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('galerie', '0007_obrazek_odstranen_datum'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='galerie',
|
||||||
|
name='poradi',
|
||||||
|
field=models.IntegerField(blank=True, default=0, verbose_name=b'Po\xc5\x99ad\xc3\xad'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -91,7 +91,7 @@ class Galerie(models.Model):
|
||||||
zobrazit = models.IntegerField('Zobrazit?', default = ORG, choices = VIDITELNOST)
|
zobrazit = models.IntegerField('Zobrazit?', default = ORG, choices = VIDITELNOST)
|
||||||
galerie_up = models.ForeignKey('Galerie', blank = True, null = True)
|
galerie_up = models.ForeignKey('Galerie', blank = True, null = True)
|
||||||
soustredeni = models.ForeignKey(Soustredeni, blank = True, null = True)
|
soustredeni = models.ForeignKey(Soustredeni, blank = True, null = True)
|
||||||
poradi = models.IntegerField('Pořadí', blank = True, null = True)
|
poradi = models.IntegerField('Pořadí', blank = True, null = False, default = 0)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.nazev
|
return self.nazev
|
||||||
|
|
|
@ -96,7 +96,7 @@ def detail(request, pk, fotka, soustredeni):
|
||||||
# Poradi aktualniho obrazku v galerii/stitku.
|
# Poradi aktualniho obrazku v galerii/stitku.
|
||||||
for i in range(len(obrazky)):
|
for i in range(len(obrazky)):
|
||||||
if obrazky[i] == obrazek:
|
if obrazky[i] == obrazek:
|
||||||
znacka = i
|
poradi = i
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
# Obrazek neni v galerii/stitku.
|
# Obrazek neni v galerii/stitku.
|
||||||
|
@ -108,11 +108,11 @@ def detail(request, pk, fotka, soustredeni):
|
||||||
# a udelat z toho funkci, ktera se pouzije u nahledu
|
# a udelat z toho funkci, ktera se pouzije u nahledu
|
||||||
predchozi_galerie = None
|
predchozi_galerie = None
|
||||||
nasledujici_galerie = None
|
nasledujici_galerie = None
|
||||||
obrazky_dalsi = obrazky[znacka+1:znacka+NAHLEDU+1]
|
obrazky_dalsi = obrazky[poradi+1:poradi+NAHLEDU+1]
|
||||||
if (znacka+1) > NAHLEDU:
|
if (poradi+1) > NAHLEDU:
|
||||||
obrazky_predchozi = obrazky[znacka-NAHLEDU:znacka]
|
obrazky_predchozi = obrazky[poradi-NAHLEDU:poradi]
|
||||||
else:
|
else:
|
||||||
obrazky_predchozi = obrazky[0:znacka]
|
obrazky_predchozi = obrazky[0:poradi]
|
||||||
if galerie.poradi > 1:
|
if galerie.poradi > 1:
|
||||||
predchozi_galerie = Galerie.objects.\
|
predchozi_galerie = Galerie.objects.\
|
||||||
filter(galerie_up=galerie.galerie_up).\
|
filter(galerie_up=galerie.galerie_up).\
|
||||||
|
@ -121,10 +121,14 @@ def detail(request, pk, fotka, soustredeni):
|
||||||
predchozi_galerie = predchozi_galerie[0]
|
predchozi_galerie = predchozi_galerie[0]
|
||||||
else:
|
else:
|
||||||
predchozi_galerie = None
|
predchozi_galerie = None
|
||||||
if (znacka+1) == len(obrazky):
|
if (poradi+1) == len(obrazky): # Tohle je poslední obrázek
|
||||||
nasledujici_galerie = Galerie.objects.\
|
if (galerie.poradi is not None
|
||||||
|
and galerie.galerie_up is not None):
|
||||||
|
nasledujici_galerie = Galerie.objects.\
|
||||||
filter(galerie_up=galerie.galerie_up).\
|
filter(galerie_up=galerie.galerie_up).\
|
||||||
filter(poradi=(galerie.poradi+1))
|
filter(poradi=(galerie.poradi+1))
|
||||||
|
else:
|
||||||
|
nasledujici_galerie = None
|
||||||
if nasledujici_galerie:
|
if nasledujici_galerie:
|
||||||
nasledujici_galerie = nasledujici_galerie[0]
|
nasledujici_galerie = nasledujici_galerie[0]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue