0.0.15 block plugin
This commit is contained in:
@@ -17,7 +17,24 @@ from django.contrib.contenttypes.fields import GenericRelation
|
||||
|
||||
# add_introspection_rules([], ["^tinymce\.models\.HTMLField"])
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
import os
|
||||
|
||||
def validate_file_extension(value):
|
||||
ext = os.path.splitext(value.name)[1] # [0] returns path & filename
|
||||
valid_extensions = ['.jpg', '.png', '.svg'] # populate with the extensions that you allow / want
|
||||
if not ext.lower() in valid_extensions:
|
||||
raise ValidationError('Unsupported file extension.')
|
||||
|
||||
|
||||
class Manager_Enabled(models.Manager):
|
||||
def get_queryset(self):
|
||||
return super(Manager_Enabled,
|
||||
self).get_queryset().filter(enable=True)
|
||||
|
||||
|
||||
class BaseModel(models.Model):
|
||||
|
||||
name = models.TextField(verbose_name=_('Название'),
|
||||
help_text=_('Название'), null=True, blank=True)
|
||||
name_plural = models.TextField(verbose_name=_('Название (множественное число)'),
|
||||
@@ -73,6 +90,9 @@ class BaseModel(models.Model):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
objects = models.Manager()
|
||||
enabled_objs = Manager_Enabled()
|
||||
|
||||
|
||||
def preSave_BaseModel(sender, instance, **kwargs):
|
||||
if instance and instance.user_profile:
|
||||
@@ -91,8 +111,8 @@ class BaseModelViewPage(BaseModel):
|
||||
help_text=_('краткое описание страницы (до 240 символов)'))
|
||||
text = RichTextUploadingField(verbose_name=_('Полное описание'), null=True, blank=True, )
|
||||
# help_text=_(u'краткое описание страницы (до 240 символов)'))
|
||||
picture = models.ImageField(upload_to='uploads/', verbose_name=_('Картинка'), null=True, blank=True,
|
||||
help_text=u'')
|
||||
picture = models.FileField(upload_to='uploads/', verbose_name=_('Картинка'), null=True, blank=True,
|
||||
validators=[validate_file_extension])
|
||||
# icon = FileBrowseField("Image", max_length=200, directory="files/", extensions=[".jpg"], blank=True, null=True)
|
||||
visible = models.BooleanField(verbose_name=_('Отображать'), default=True)
|
||||
# background_image_left = models.ImageField(verbose_name=_('Левая подложка'), blank=True, null=True)
|
||||
@@ -110,10 +130,10 @@ class BaseModelViewPage(BaseModel):
|
||||
|
||||
blocks = GenericRelation('GeneralApp.Block', related_query_name='grel_%(class)s_for_block_item')
|
||||
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
def get_description_exists(self):
|
||||
if self.description:
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user