cms.plugins.flash.models: 19 total statements, 0.0% covered

Generated: Wed 2013-03-13 10:33 CET

Source file: /media/Envs/Envs/filer-gallery/lib/python2.7/site-packages/cms/plugins/flash/models.py

Stats: 0 executed, 12 missed, 7 excluded, 6 ignored

  1. import re
  2. from django.db import models
  3. from django.utils.translation import ugettext_lazy as _
  4. from cms.models import CMSPlugin
  5. from os.path import basename
  6. class Flash(CMSPlugin):
  7. file = models.FileField(_('file'), upload_to=CMSPlugin.get_media_path, help_text=_('use swf file'))
  8. width = models.CharField(_('width'), max_length=6)
  9. height = models.CharField(_('height'), max_length=6)
  10. def get_height(self):
  11. return fix_unit(self.height)
  12. def get_width(self):
  13. return fix_unit(self.width)
  14. def __unicode__(self):
  15. return u"%s" % basename(self.file.path)
  16. def fix_unit(value):
  17. if not re.match(r'.*[0-9]$', value):
  18. # no unit, add px
  19. return value + "px"
  20. return value