From 7e070f5f05c7ead507d62e62cd4f8a16852ca345 Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Mon, 9 Dec 2019 23:21:41 +0100 Subject: [PATCH 1/5] =?UTF-8?q?Galerie:=20p=C5=99ejmenov=C3=A1na=20`znacka?= =?UTF-8?q?`=20na=20`poradi`,=20aby=20to=20d=C3=A1valo=20aspo=C5=88=20troc?= =?UTF-8?q?hu=20smysl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- galerie/views.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/galerie/views.py b/galerie/views.py index 807b6de4..7d37c6be 100644 --- a/galerie/views.py +++ b/galerie/views.py @@ -96,7 +96,7 @@ def detail(request, pk, fotka, soustredeni): # Poradi aktualniho obrazku v galerii/stitku. for i in range(len(obrazky)): if obrazky[i] == obrazek: - znacka = i + poradi = i break else: # 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 predchozi_galerie = None nasledujici_galerie = None - obrazky_dalsi = obrazky[znacka+1:znacka+NAHLEDU+1] - if (znacka+1) > NAHLEDU: - obrazky_predchozi = obrazky[znacka-NAHLEDU:znacka] + obrazky_dalsi = obrazky[poradi+1:poradi+NAHLEDU+1] + if (poradi+1) > NAHLEDU: + obrazky_predchozi = obrazky[poradi-NAHLEDU:poradi] else: - obrazky_predchozi = obrazky[0:znacka] + obrazky_predchozi = obrazky[0:poradi] if galerie.poradi > 1: predchozi_galerie = Galerie.objects.\ filter(galerie_up=galerie.galerie_up).\ @@ -121,7 +121,7 @@ def detail(request, pk, fotka, soustredeni): predchozi_galerie = predchozi_galerie[0] else: predchozi_galerie = None - if (znacka+1) == len(obrazky): + if (poradi+1) == len(obrazky): nasledujici_galerie = Galerie.objects.\ filter(galerie_up=galerie.galerie_up).\ filter(poradi=(galerie.poradi+1)) From b5c4fa1f8f2f1376621bb9afb5aca00a60add719 Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Mon, 9 Dec 2019 23:23:34 +0100 Subject: [PATCH 2/5] =?UTF-8?q?Galerie:=20V=C3=BDchoz=C3=AD=20po=C5=99ad?= =?UTF-8?q?=C3=AD=20galerie=20je=20nula?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Jinak se nedá zobrazit poslední obrázek galerie --- galerie/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/galerie/models.py b/galerie/models.py index 3cc4b682..1b64194c 100644 --- a/galerie/models.py +++ b/galerie/models.py @@ -91,7 +91,7 @@ class Galerie(models.Model): zobrazit = models.IntegerField('Zobrazit?', default = ORG, choices = VIDITELNOST) galerie_up = models.ForeignKey('Galerie', 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): return self.nazev From b7387571da14f5a29c39afddb279512fe76ffdae Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Mon, 9 Dec 2019 23:46:00 +0100 Subject: [PATCH 3/5] =?UTF-8?q?Galerie:=20Nespadneme,=20pokud=20nen=C3=AD?= =?UTF-8?q?=20nastaven=C3=A9=20=C4=8D=C3=ADslo=20galerie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ano, vím, že jsem to před chvílí opravil i jinak, ale co. --- galerie/views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/galerie/views.py b/galerie/views.py index 7d37c6be..11c01f33 100644 --- a/galerie/views.py +++ b/galerie/views.py @@ -121,10 +121,14 @@ def detail(request, pk, fotka, soustredeni): predchozi_galerie = predchozi_galerie[0] else: predchozi_galerie = None - if (poradi+1) == len(obrazky): - nasledujici_galerie = Galerie.objects.\ + if (poradi+1) == len(obrazky): # Tohle je poslední obrázek + if galerie.poradi is not None + and galerie.galerie_up is not None: + nasledujici_galerie = Galerie.objects.\ filter(galerie_up=galerie.galerie_up).\ filter(poradi=(galerie.poradi+1)) + else: + nasledujici_galerie = None if nasledujici_galerie: nasledujici_galerie = nasledujici_galerie[0] else: From ac56fd056353a07c53624aedd6620b2806462ea9 Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Mon, 9 Dec 2019 23:46:40 +0100 Subject: [PATCH 4/5] Galerie: Migrace k b5c4fa1 --- galerie/migrations/0008_auto_20191209_2326.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 galerie/migrations/0008_auto_20191209_2326.py diff --git a/galerie/migrations/0008_auto_20191209_2326.py b/galerie/migrations/0008_auto_20191209_2326.py new file mode 100644 index 00000000..12e605f4 --- /dev/null +++ b/galerie/migrations/0008_auto_20191209_2326.py @@ -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'), + ), + ] From 1722283a75b35b9baa1608efadfc46e1dc4bf114 Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Mon, 9 Dec 2019 23:52:12 +0100 Subject: [PATCH 5/5] Galerie: Fix syntax --- galerie/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/galerie/views.py b/galerie/views.py index 11c01f33..916a869b 100644 --- a/galerie/views.py +++ b/galerie/views.py @@ -122,8 +122,8 @@ def detail(request, pk, fotka, soustredeni): else: predchozi_galerie = None if (poradi+1) == len(obrazky): # Tohle je poslední obrázek - if galerie.poradi is not None - and galerie.galerie_up is not None: + if (galerie.poradi is not None + and galerie.galerie_up is not None): nasledujici_galerie = Galerie.objects.\ filter(galerie_up=galerie.galerie_up).\ filter(poradi=(galerie.poradi+1))