Browse Source

Move rozdělení tvorby a novinek v models

export_seznamu_prednasek
Jonas Havelka 3 years ago
parent
commit
4009aedff0
  1. 3
      seminar/models/__init__.py
  2. 38
      seminar/models/novinky.py
  3. 2
      seminar/models/odevzdavatko.py
  4. 2
      seminar/models/soustredeni.py
  5. 2
      seminar/models/treenode.py
  6. 34
      seminar/models/tvorba.py

3
seminar/models/__init__.py

@ -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 *

38
seminar/models/novinky.py

@ -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) + '] '

2
seminar/models/odevzdavatko.py

@ -9,7 +9,7 @@ from django.urls import reverse_lazy
from django.utils import timezone
from django.conf import settings
from seminar.models import models_all as am
from seminar.models import tvorba as am
from seminar.models import personalni as pm
from seminar.models import treenode as tm
from seminar.models.base import SeminarModelBase

2
seminar/models/soustredeni.py

@ -11,7 +11,7 @@ from django.conf import settings
from . import personalni as pm
from .base import SeminarModelBase
from seminar.models import models_all as am
from seminar.models import tvorba as am
logger = logging.getLogger(__name__)

2
seminar/models/treenode.py

@ -15,7 +15,7 @@ from .pomocne import Text
logger = logging.getLogger(__name__)
from seminar.models import models_all as am
from seminar.models import tvorba as am
class TreeNode(PolymorphicModel):
class Meta:

34
seminar/models/models_all.py → seminar/models/tvorba.py

@ -13,8 +13,6 @@ from django.urls import reverse
from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.utils.text import get_valid_filename
from imagekit.models import ImageSpecField
from imagekit.processors import ResizeToFit
from django.utils.functional import cached_property
from solo.models import SingletonModel
@ -645,35 +643,3 @@ class Nastaveni(SingletonModel):
def verejne(self):
return False
@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…
Cancel
Save