Web M&M
https://mam.matfyz.cz
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
39 lines
1.3 KiB
3 years ago
|
from django.db import models
|
||
|
from imagekit.models import ImageSpecField
|
||
|
from imagekit.processors import ResizeToFit
|
||
|
|
||
|
from reversion import revisions as reversion
|
||
|
|
||
|
from . import personalni as pm
|
||
|
|
||
|
@reversion.register(ignore_duplicates=True)
|
||
|
class Novinky(models.Model):
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name = 'Novinka'
|
||
|
verbose_name_plural = 'Novinky'
|
||
|
ordering = ['-datum']
|
||
|
|
||
|
datum = models.DateField(auto_now_add=True)
|
||
|
|
||
|
text = models.TextField('Text novinky', blank=True, null=True)
|
||
|
obrazek = models.ImageField('Obrázek', upload_to='image_novinky/%Y/%m/%d/',
|
||
|
null=True, blank=True)
|
||
|
|
||
|
obrazek_maly = ImageSpecField(source='obrazek',
|
||
|
processors=[
|
||
|
ResizeToFit(350, 200, upscale=False)
|
||
|
],
|
||
|
options={'quality': 95})
|
||
|
|
||
|
autor = models.ForeignKey(pm.Organizator, verbose_name='Autor novinky', null=True,
|
||
|
on_delete=models.SET_NULL)
|
||
|
|
||
|
zverejneno = models.BooleanField('Zveřejněno', default=False)
|
||
|
|
||
|
def __str__(self):
|
||
|
if self.text:
|
||
|
return '[' + str(self.datum) + '] ' + self.text[0:50]
|
||
|
else:
|
||
|
return '[' + str(self.datum) + '] '
|