|
|
@ -47,13 +47,13 @@ def obrazek_filename(self, filename): |
|
|
|
|
|
|
|
class Obrazek(models.Model): |
|
|
|
obrazek_velky = models.ImageField(upload_to=obrazek_filename, |
|
|
|
help_text = "Lze vložit libovolně velký obrázek. Ideální je, aby alespoň jeden rozměr měl alespoň 500px.") |
|
|
|
help_text = "Lze vložit libovolně velký obrázek. Ideální je, aby alespoň jeden rozměr měl alespoň 500px.") |
|
|
|
obrazek_stredni = ImageSpecField(source='obrazek_velky', |
|
|
|
processors=[Transpose(Transpose.AUTO), ResizeToFit(900, 675, upscale=False)], |
|
|
|
options={'quality': 95}) |
|
|
|
processors=[Transpose(Transpose.AUTO), ResizeToFit(900, 675, upscale=False)], |
|
|
|
options={'quality': 95}) |
|
|
|
obrazek_maly = ImageSpecField(source='obrazek_velky', |
|
|
|
processors=[Transpose(Transpose.AUTO), ResizeToFit(167, 167, upscale=False)], |
|
|
|
options={'quality': 95}) |
|
|
|
processors=[Transpose(Transpose.AUTO), ResizeToFit(167, 167, upscale=False)], |
|
|
|
options={'quality': 95}) |
|
|
|
nazev = models.CharField('Název', max_length=50, blank=True, null=True) |
|
|
|
popis = models.TextField('Popis', blank=True, null=True) |
|
|
|
datum_vlozeni = models.DateTimeField('Datum vložení', auto_now_add=True) |
|
|
@ -61,15 +61,15 @@ class Obrazek(models.Model): |
|
|
|
poradi = models.IntegerField('Pořadí', blank=True, null=True) |
|
|
|
|
|
|
|
def __unicode__(self): |
|
|
|
return unicode(self.obrazek_velky.name) |
|
|
|
return unicode(self.obrazek_velky.name) |
|
|
|
|
|
|
|
class Meta: |
|
|
|
verbose_name = 'Obrázek' |
|
|
|
verbose_name_plural = 'Obrázky' |
|
|
|
ordering = ['nazev'] |
|
|
|
verbose_name = 'Obrázek' |
|
|
|
verbose_name_plural = 'Obrázky' |
|
|
|
ordering = ['nazev'] |
|
|
|
|
|
|
|
def obrazek_maly_tag(self): |
|
|
|
return u'<img src="{}">'.format(self.obrazek_maly.url) |
|
|
|
return u'<img src="{}">'.format(self.obrazek_maly.url) |
|
|
|
obrazek_maly_tag.short_description = "Náhled" |
|
|
|
obrazek_maly_tag.allow_tags = True |
|
|
|
|
|
|
@ -80,43 +80,42 @@ class Obrazek(models.Model): |
|
|
|
self.nazev = os.path.basename(self.obrazek_velky.name) |
|
|
|
super(Obrazek, self).save(*args, **kwargs) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Galerie(models.Model): |
|
|
|
nazev = models.CharField('Název', max_length=100) |
|
|
|
datum_vytvoreni = models.DateTimeField('Datum vytvoření', auto_now_add = True) |
|
|
|
datum_zmeny = models.DateTimeField('Datum poslední změny', auto_now = True) |
|
|
|
popis = models.TextField('Popis', blank = True, null = True) |
|
|
|
titulni_obrazek = models.ForeignKey(Obrazek, blank = True, null = True, related_name = "+", on_delete = models.SET_NULL) |
|
|
|
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) |
|
|
|
|
|
|
|
def __unicode__(self): |
|
|
|
return self.nazev |
|
|
|
class Meta: |
|
|
|
verbose_name = 'Galerie' |
|
|
|
verbose_name_plural = 'Galerie' |
|
|
|
|
|
|
|
#def link_na_preview(self): |
|
|
|
#"""Odkaz na galerii, používá se v admin rozhranní. """ |
|
|
|
#return '<a href="/fotogalerie/galerie/%s/">Preview</a>' % self.id |
|
|
|
#link_na_preview.allow_tags = True |
|
|
|
#link_na_preview.short_description = 'Zobrazit galerii' |
|
|
|
nazev = models.CharField('Název', max_length=100) |
|
|
|
datum_vytvoreni = models.DateTimeField('Datum vytvoření', auto_now_add = True) |
|
|
|
datum_zmeny = models.DateTimeField('Datum poslední změny', auto_now = True) |
|
|
|
popis = models.TextField('Popis', blank = True, null = True) |
|
|
|
titulni_obrazek = models.ForeignKey(Obrazek, blank = True, null = True, related_name = "+", on_delete = models.SET_NULL) |
|
|
|
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) |
|
|
|
|
|
|
|
def __unicode__(self): |
|
|
|
return self.nazev |
|
|
|
class Meta: |
|
|
|
verbose_name = 'Galerie' |
|
|
|
verbose_name_plural = 'Galerie' |
|
|
|
|
|
|
|
#def link_na_preview(self): |
|
|
|
#"""Odkaz na galerii, používá se v admin rozhranní. """ |
|
|
|
#return '<a href="/fotogalerie/galerie/%s/">Preview</a>' % self.id |
|
|
|
#link_na_preview.allow_tags = True |
|
|
|
#link_na_preview.short_description = 'Zobrazit galerii' |
|
|
|
# |
|
|
|
#def je_publikovano(self): |
|
|
|
#"""Vraci True, pokud je tato galerie publikovana. """ |
|
|
|
#if self.zobrazit == VZDY: |
|
|
|
#return True |
|
|
|
#if self.zobrazit == PODLE_CLANKU: |
|
|
|
#for clanek in self.clanek_set.all(): |
|
|
|
#if clanek.je_publikovano(): |
|
|
|
#return True |
|
|
|
#return False |
|
|
|
#def je_publikovano(self): |
|
|
|
#"""Vraci True, pokud je tato galerie publikovana. """ |
|
|
|
#if self.zobrazit == VZDY: |
|
|
|
#return True |
|
|
|
#if self.zobrazit == PODLE_CLANKU: |
|
|
|
#for clanek in self.clanek_set.all(): |
|
|
|
#if clanek.je_publikovano(): |
|
|
|
#return True |
|
|
|
#return False |
|
|
|
# |
|
|
|
#@staticmethod |
|
|
|
#def publikovane_galerie(): |
|
|
|
#"""Vraci galerie, ktere uz maji byt publikovane.""" |
|
|
|
#clanky = Blog.models.Clanek.publikovane_clanky() |
|
|
|
#return Galerie.objects.filter(Q(zobrazit=VZDY) | (Q(clanek__in=clanky) & Q(zobrazit=PODLE_CLANKU))).distinct() |
|
|
|
#@staticmethod |
|
|
|
#def publikovane_galerie(): |
|
|
|
#"""Vraci galerie, ktere uz maji byt publikovane.""" |
|
|
|
#clanky = Blog.models.Clanek.publikovane_clanky() |
|
|
|
#return Galerie.objects.filter(Q(zobrazit=VZDY) | (Q(clanek__in=clanky) & Q(zobrazit=PODLE_CLANKU))).distinct() |
|
|
|