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.
40 lines
1.1 KiB
40 lines
1.1 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
|
||
|
|
||
8 months ago
|
from personalni.models import Organizator
|
||
3 years ago
|
|
||
|
@reversion.register(ignore_duplicates=True)
|
||
|
class Novinky(models.Model):
|
||
|
|
||
2 years ago
|
class Meta:
|
||
|
verbose_name = 'Novinka'
|
||
|
verbose_name_plural = 'Novinky'
|
||
|
ordering = ['-datum']
|
||
7 months ago
|
db_table = 'seminar_novinky'
|
||
3 years ago
|
|
||
2 years ago
|
datum = models.DateField(auto_now_add=True)
|
||
3 years ago
|
|
||
2 years ago
|
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)
|
||
3 years ago
|
|
||
2 years ago
|
obrazek_maly = ImageSpecField(source='obrazek',
|
||
|
processors=[
|
||
|
ResizeToFit(350, 200, upscale=False)
|
||
|
],
|
||
|
options={'quality': 95})
|
||
3 years ago
|
|
||
8 months ago
|
autor = models.ForeignKey(Organizator, verbose_name='Autor novinky', null=True,
|
||
2 years ago
|
on_delete=models.SET_NULL)
|
||
3 years ago
|
|
||
2 years ago
|
zverejneno = models.BooleanField('Zveřejněno', default=False)
|
||
3 years ago
|
|
||
2 years ago
|
def __str__(self):
|
||
|
if self.text:
|
||
|
return '[' + str(self.datum) + '] ' + self.text[0:50]
|
||
|
else:
|
||
|
return '[' + str(self.datum) + '] '
|