Browse files

Removed useless version check.

No longer serves a purpose after 48f8e0a.
  • Loading branch information...
1 parent 65dfc7b commit ef9283397a06554daaa9e5dcd413599cd156dee5 @timgraham timgraham committed Jan 25, 2014
Showing with 19 additions and 28 deletions.
  1. +11 −16 cmsplugin_filer_image/models.py
  2. +8 −12 cmsplugin_filer_teaser/models.py
View
27 cmsplugin_filer_image/models.py
@@ -1,12 +1,10 @@
-import django
from django.utils.translation import ugettext_lazy as _
from django.db import models
from cms.models import CMSPlugin
from cms.models.fields import PageField
from filer.fields.image import FilerImageField
from filer.fields.file import FilerFileField
from cmsplugin_filer_utils import FilerPluginManager
-from distutils.version import LooseVersion
class FilerImage(CMSPlugin):
@@ -17,26 +15,23 @@ class FilerImage(CMSPlugin):
)
caption_text = models.CharField(_("caption text"), null=True, blank=True, max_length=255)
image = FilerImageField(null=True, blank=True, default=None, verbose_name=_("image"))
- if LooseVersion(django.get_version()) < LooseVersion('1.5'):
- image_url = models.URLField(_("alternative image url"), null=True, blank=True, default=None)
- else:
- image_url = models.URLField(_("alternative image url"), null=True, blank=True, default=None)
+ image_url = models.URLField(_("alternative image url"), null=True, blank=True, default=None)
alt_text = models.CharField(_("alt text"), null=True, blank=True, max_length=255)
use_original_image = models.BooleanField(_("use the original image"), default=False,
help_text=_('do not resize the image. use the original image instead.'))
thumbnail_option = models.ForeignKey('ThumbnailOption', null=True, blank=True, verbose_name=_("thumbnail option"),
help_text=_('overrides width, height, crop and upscale with values from the selected thumbnail option'))
- use_autoscale = models.BooleanField(_("use automatic scaling"), default=False,
+ use_autoscale = models.BooleanField(_("use automatic scaling"), default=False,
help_text=_('tries to auto scale the image based on the placeholder context'))
width = models.PositiveIntegerField(_("width"), null=True, blank=True)
height = models.PositiveIntegerField(_("height"), null=True, blank=True)
crop = models.BooleanField(_("crop"), default=True)
upscale = models.BooleanField(_("upscale"), default=True)
alignment = models.CharField(_("image alignment"), max_length=10, blank=True, null=True, choices=FLOAT_CHOICES)
-
- free_link = models.CharField(_("link"), max_length=255, blank=True, null=True,
+
+ free_link = models.CharField(_("link"), max_length=255, blank=True, null=True,
help_text=_("if present image will be clickable"))
- page_link = PageField(null=True, blank=True,
+ page_link = PageField(null=True, blank=True,
help_text=_("if present image will be clickable"),
verbose_name=_("page link"))
file_link = FilerFileField(null=True, blank=True, default=None, verbose_name=_("file link"), help_text=_("if present image will be clickable"), related_name='+')
@@ -53,14 +48,14 @@ class FilerImage(CMSPlugin):
class Meta:
verbose_name = _("filer image")
verbose_name_plural = _("filer images")
-
+
def clean(self):
from django.core.exceptions import ValidationError
# Make sure that either image or image_url is set
if (not self.image and not self.image_url) or (self.image and self.image_url):
raise ValidationError(_('Either an image or an image url must be selected.'))
-
+
def __unicode__(self):
if self.image:
return self.image.label
@@ -94,8 +89,8 @@ def link(self):
return self.image_url
else:
return ''
-
-
+
+
class ThumbnailOption(models.Model):
"""
This class defines the option use to create the thumbnail.
@@ -105,12 +100,12 @@ class ThumbnailOption(models.Model):
height = models.IntegerField(_("height"), help_text=_('height in pixel.'))
crop = models.BooleanField(_("crop"), default=True)
upscale = models.BooleanField(_("upscale"), default=True)
-
+
class Meta:
ordering = ('width', 'height')
verbose_name = _("thumbnail option")
verbose_name_plural = _("thumbnail options")
-
+
def __unicode__(self):
return u'%s -- %s x %s' %(self.name, self.width, self.height)
View
20 cmsplugin_filer_teaser/models.py
@@ -5,7 +5,6 @@
from cms.models.fields import PageField
from filer.fields.image import FilerImageField
from django.conf import settings
-from distutils.version import LooseVersion
from cmsplugin_filer_utils import FilerPluginManager
@@ -17,32 +16,29 @@ class FilerTeaser(CMSPlugin):
"""
title = models.CharField(_("title"), max_length=255, blank=True)
image = FilerImageField(blank=True, null=True, verbose_name=_("image"))
- if LooseVersion(django.get_version()) < LooseVersion('1.5'):
- image_url = models.URLField(_("alternative image url"), null=True, blank=True, default=None)
- else:
- image_url = models.URLField(_("alternative image url"), null=True, blank=True, default=None)
-
+ image_url = models.URLField(_("alternative image url"), null=True, blank=True, default=None)
+
style = models.CharField(_("teaser style"), max_length=255, null=True, blank=True, choices=CMSPLUGIN_FILER_TEASER_STYLE_CHOICES)
-
- use_autoscale = models.BooleanField(_("use automatic scaling"), default=True,
+
+ use_autoscale = models.BooleanField(_("use automatic scaling"), default=True,
help_text=_('tries to auto scale the image based on the placeholder context'))
width = models.PositiveIntegerField(_("width"), null=True, blank=True)
height = models.PositiveIntegerField(_("height"), null=True, blank=True)
-
+
free_link = models.CharField(_("link"), max_length=255, blank=True, null=True, help_text=_("if present image will be clickable"))
page_link = PageField(null=True, blank=True, help_text=_("if present image will be clickable"), verbose_name=_("page link"))
description = models.TextField(_("description"), blank=True, null=True)
-
+
target_blank = models.BooleanField(_("open link in new window"), default=False)
objects = FilerPluginManager(select_related=('image', 'page_link'))
-
+
def clean(self):
from django.core.exceptions import ValidationError
# Make sure that either image or image_url is set
if self.image and self.image_url:
raise ValidationError(_('Either an image or an image url must be selected.'))
-
+
def __unicode__(self):
return self.title

0 comments on commit ef92833

Please sign in to comment.