Permalink
Browse files

Added Python 3.3 compatibility.

  • Loading branch information...
1 parent d722bca commit 3429eb89d0083139f5a7ff5df95ccf50301b8fb3 @timgraham timgraham committed Jan 25, 2014
@@ -1,10 +1,13 @@
+from __future__ import unicode_literals
+
from cms.plugin_pool import plugin_pool
from cms.plugin_base import CMSPluginBase
from django.template.loader import select_template
from django.utils.translation import ugettext_lazy as _
-import models
+from . import models
from .conf import settings
+
class FilerFilePlugin(CMSPluginBase):
module = 'Filer'
model = models.FilerFile
@@ -38,6 +41,6 @@ def render(self, context, instance, placeholder):
def icon_src(self, instance):
file_icon = instance.get_icon_url()
if file_icon: return file_icon
- return settings.CMS_MEDIA_URL + u"images/plugins/file.png"
+ return settings.CMS_MEDIA_URL + "images/plugins/file.png"
plugin_pool.register_plugin(FilerFilePlugin)
@@ -1,11 +1,16 @@
+from __future__ import unicode_literals
+
from cms.models import CMSPlugin
from django.db import models
from django.utils.translation import ugettext_lazy as _
from filer.fields.file import FilerFileField
+from filer.utils.compatibility import python_2_unicode_compatible
+
from cmsplugin_filer_utils import FilerPluginManager
from .conf import settings
+@python_2_unicode_compatible
class FilerFile(CMSPlugin):
"""
Plugin for storing any type of file.
@@ -35,15 +40,15 @@ def file_exists(self):
def get_file_name(self):
if self.file.name in ('', None):
- name = u"%s" % (self.file.original_filename,)
+ name = "%s" % (self.file.original_filename,)
else:
- name = u"%s" % (self.file.name,)
+ name = "%s" % (self.file.name,)
return name
def get_ext(self):
return self.file.extension
- def __unicode__(self):
+ def __str__(self):
if self.title:
return self.title
elif self.file:
@@ -1,16 +1,20 @@
+from __future__ import unicode_literals
+
import warnings
from django.db import models
from cms.models import CMSPlugin
from django.utils.translation import ugettext_lazy as _
from filer.fields.folder import FilerFolderField
+from filer.utils.compatibility import python_2_unicode_compatible
from .conf import settings
from cmsplugin_filer_utils import FilerPluginManager
+@python_2_unicode_compatible
class FilerFolder(CMSPlugin):
"""
Plugin for storing any type of Folder.
-
+
Default template displays files store inside this folder.
"""
STYLE_CHOICES = settings.CMSPLUGIN_FILER_FOLDER_STYLE_CHOICES
@@ -27,14 +31,13 @@ def view_option(self):
warnings.warn("view_option on cmsplugin_filer_folder.FilderFolder is deprecated. Use .style instead.",
DeprecationWarning)
return self.style
-
- def __unicode__(self):
- if self.title:
+
+ def __str__(self):
+ if self.title:
return self.title
elif self.folder.name:
# added if, because it raised attribute error when file wasnt defined
return self.folder.name
return "<empty>"
search_fields = ('title',)
-
@@ -1,5 +1,5 @@
from django.contrib import admin
-from models import ThumbnailOption
+from .models import ThumbnailOption
class ThumbnailOptionAdmin(admin.ModelAdmin):
list_display = ('name', 'width', 'height')
@@ -1,9 +1,11 @@
-from django.template.loader import select_template
+from __future__ import unicode_literals
+
import os
from cms.plugin_pool import plugin_pool
from cms.plugin_base import CMSPluginBase
+from django.template.loader import select_template
from django.utils.translation import ugettext_lazy as _
-import models
+from . import models
from .conf import settings
from filer.settings import FILER_STATICMEDIA_PREFIX
@@ -124,5 +126,5 @@ def icon_src(self, instance):
thumbnail = self.get_thumbnail({'width': 200}, instance)
return thumbnail.url
else:
- return os.path.normpath(u"%s/icons/missingfile_%sx%s.png" % (FILER_STATICMEDIA_PREFIX, 32, 32,))
+ return os.path.normpath("%s/icons/missingfile_%sx%s.png" % (FILER_STATICMEDIA_PREFIX, 32, 32,))
plugin_pool.register_plugin(FilerImagePlugin)
@@ -1,13 +1,17 @@
+from __future__ import unicode_literals
+
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 filer.utils.compatibility import python_2_unicode_compatible
from cmsplugin_filer_utils import FilerPluginManager
from .conf import settings
+@python_2_unicode_compatible
class FilerImage(CMSPlugin):
LEFT = "left"
RIGHT = "right"
@@ -61,11 +65,11 @@ def clean(self):
raise ValidationError(_('Either an image or an image url must be selected.'))
- def __unicode__(self):
+ def __str__(self):
if self.image:
return self.image.label
else:
- return unicode( _("Image Publication %(caption)s") % {'caption': self.caption or self.alt} )
+ return _("Image Publication %(caption)s") % {'caption': self.caption or self.alt}
return ''
@property
def caption(self):
@@ -96,6 +100,7 @@ def link(self):
return ''
+@python_2_unicode_compatible
class ThumbnailOption(models.Model):
"""
This class defines the option use to create the thumbnail.
@@ -111,8 +116,8 @@ class Meta:
verbose_name = _("thumbnail option")
verbose_name_plural = _("thumbnail options")
- def __unicode__(self):
- return u'%s -- %s x %s' %(self.name, self.width, self.height)
+ def __str__(self):
+ return '%s -- %s x %s' % (self.name, self.width, self.height)
@property
def as_dict(self):
@@ -1,13 +1,15 @@
+from __future__ import unicode_literals
+
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from django.utils.translation import ugettext as _
from django.conf import settings
-from models import FilerLinkPlugin
+from .models import FilerLinkPlugin
class FilerLinkPlugin(CMSPluginBase):
module = 'Filer'
- model = FilerLinkPlugin
+ model = FilerLinkPlugin
name = _("Link")
text_enabled = True
render_template = "cmsplugin_filer_link/link.html"
@@ -16,7 +18,7 @@ def render(self, context, instance, placeholder):
if instance.file:
link = instance.file.url
elif instance.mailto:
- link = u"mailto:%s" % _(instance.mailto)
+ link = "mailto:%s" % _(instance.mailto)
elif instance.url:
link = _(instance.url)
elif instance.page_link:
@@ -32,7 +34,7 @@ def render(self, context, instance, placeholder):
return context
def icon_src(self, instance):
- return settings.STATIC_URL + u"cms/images/plugins/link.png"
+ return settings.STATIC_URL + "cms/images/plugins/link.png"
-plugin_pool.register_plugin(FilerLinkPlugin)
+plugin_pool.register_plugin(FilerLinkPlugin)
@@ -4,13 +4,16 @@
from cms.models import CMSPlugin, Page
from cms.models.fields import PageField
from filer.fields.file import FilerFileField
+from filer.utils.compatibility import python_2_unicode_compatible
DEFULT_LINK_STYLES = (
(" ", "Default"),
)
LINK_STYLES = getattr(settings, "FILER_LINK_STYLES", DEFULT_LINK_STYLES)
+
+@python_2_unicode_compatible
class FilerLinkPlugin(CMSPlugin):
name = models.CharField(_('name'), max_length=255)
url = models.CharField(_("url"), blank=True, null=True, max_length=255)
@@ -25,6 +28,5 @@ class FilerLinkPlugin(CMSPlugin):
file = FilerFileField(blank=True, null=True)
- def __unicode__(self):
- return u'%s' % self.name
-
+ def __str__(self):
+ return self.name
@@ -4,10 +4,12 @@
from cms.models import CMSPlugin
from cms.models.fields import PageField
from filer.fields.image import FilerImageField
+from filer.utils.compatibility import python_2_unicode_compatible
from .conf import settings
from cmsplugin_filer_utils import FilerPluginManager
+@python_2_unicode_compatible
class FilerTeaser(CMSPlugin):
"""
A Teaser
@@ -38,7 +40,7 @@ def clean(self):
if self.image and self.image_url:
raise ValidationError(_('Either an image or an image url must be selected.'))
- def __unicode__(self):
+ def __str__(self):
return self.title
@property
@@ -50,5 +52,5 @@ def link(self):
return self.page_link.get_absolute_url()
else:
return ''
- except Exception, e:
- print e
+ except Exception as e:
+ print(e)
@@ -1,3 +1,5 @@
+from __future__ import unicode_literals
+
import os
from cms.plugin_pool import plugin_pool
from cms.plugin_base import CMSPluginBase
@@ -57,5 +59,5 @@ def render(self, context, instance, placeholder):
return context
def icon_src(self, instance):
- return os.path.normpath(u"%s/icons/video_%sx%s.png" % (FILER_STATICMEDIA_PREFIX, 32, 32,))
+ return os.path.normpath("%s/icons/video_%sx%s.png" % (FILER_STATICMEDIA_PREFIX, 32, 32,))
plugin_pool.register_plugin(FilerVideoPlugin)
@@ -1,53 +1,57 @@
+from __future__ import unicode_literals
+
from cms.models import CMSPlugin
from cmsplugin_filer_video import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _
from filer.fields.file import FilerFileField
from filer.fields.image import FilerImageField
+from filer.utils.compatibility import python_2_unicode_compatible
from os.path import basename
import re
+
+@python_2_unicode_compatible
class FilerVideo(CMSPlugin):
# player settings
movie = FilerFileField(verbose_name=_('movie file'), help_text=_('use .flv file or h264 encoded video file'), blank=True, null=True)
movie_url = models.CharField(_('movie url'), max_length=255, help_text=_('vimeo or youtube video url. Example: http://www.youtube.com/watch?v=YFa59lK-kpo'), blank=True, null=True)
image = FilerImageField(verbose_name=_('image'), help_text=_('preview image file'), null=True, blank=True, related_name='filer_video_image')
-
+
width = models.PositiveSmallIntegerField(_('width'), default=settings.VIDEO_WIDTH)
height = models.PositiveSmallIntegerField(_('height'), default=settings.VIDEO_HEIGHT)
-
+
auto_play = models.BooleanField(_('auto play'), default=settings.VIDEO_AUTOPLAY)
auto_hide = models.BooleanField(_('auto hide'), default=settings.VIDEO_AUTOHIDE)
fullscreen = models.BooleanField(_('fullscreen'), default=settings.VIDEO_FULLSCREEN)
loop = models.BooleanField(_('loop'), default=settings.VIDEO_LOOP)
-
+
# plugin settings
bgcolor = models.CharField(_('background color'), max_length=6, default=settings.VIDEO_BG_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
textcolor = models.CharField(_('text color'), max_length=6, default=settings.VIDEO_TEXT_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
seekbarcolor = models.CharField(_('seekbar color'), max_length=6, default=settings.VIDEO_SEEKBAR_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
seekbarbgcolor = models.CharField(_('seekbar bg color'), max_length=6, default=settings.VIDEO_SEEKBARBG_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
loadingbarcolor = models.CharField(_('loadingbar color'), max_length=6, default=settings.VIDEO_LOADINGBAR_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
buttonoutcolor = models.CharField(_('button out color'), max_length=6, default=settings.VIDEO_BUTTON_OUT_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
- buttonovercolor = models.CharField(_('button over color'), max_length=6, default=settings.VIDEO_BUTTON_OVER_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
+ buttonovercolor = models.CharField(_('button over color'), max_length=6, default=settings.VIDEO_BUTTON_OVER_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
buttonhighlightcolor = models.CharField(_('button highlight color'), max_length=6, default=settings.VIDEO_BUTTON_HIGHLIGHT_COLOR, help_text=_('Hexadecimal, eg ff00cc'))
-
-
- def __unicode__(self):
+
+
+ def __str__(self):
if self.movie:
name = self.movie.path
else:
name = self.movie_url
- return u"%s" % basename(name)
+ return "%s" % basename(name)
def get_height(self):
return "%s" % (self.height)
-
+
def get_width(self):
- return "%s" % (self.width)
-
+ return "%s" % (self.width)
+
def get_movie(self):
if self.movie:
return self.movie.url
else:
return self.movie_url
-

0 comments on commit 3429eb8

Please sign in to comment.