Jonas Havelka
3 years ago
6 changed files with 43 additions and 38 deletions
@ -1,7 +1,8 @@ |
|||
from .models_all import * |
|||
from .tvorba import * |
|||
from .odevzdavatko import * |
|||
from .base import * |
|||
from .personalni import * |
|||
from .soustredeni import * |
|||
from .pomocne import * |
|||
from .treenode import * |
|||
from .novinky import * |
|||
|
@ -0,0 +1,38 @@ |
|||
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) + '] ' |
Loading…
Reference in new issue