cms.plugins.picture.models: 24 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/picture/models.py

Stats: 0 executed, 11 missed, 13 excluded, 12 ignored

  1. from django.db import models
  2. from django.utils.translation import ugettext_lazy as _
  3. from cms.models import CMSPlugin, Page
  4. from os.path import basename
  5. class Picture(CMSPlugin):
  6. """
  7. A Picture with or without a link
  8. """
  9. CENTER = "center"
  10. LEFT = "left"
  11. RIGHT = "right"
  12. FLOAT_CHOICES = ((CENTER, _("center")),
  13. (LEFT, _("left")),
  14. (RIGHT, _("right")),
  15. )
  16. image = models.ImageField(_("image"), upload_to=CMSPlugin.get_media_path)
  17. url = models.CharField(_("link"), max_length=255, blank=True, null=True, help_text=_("if present image will be clickable"))
  18. page_link = models.ForeignKey(Page, verbose_name=_("page"), null=True, blank=True, help_text=_("if present image will be clickable"))
  19. alt = models.CharField(_("alternate text"), max_length=255, blank=True, null=True, help_text=_("textual description of the image"))
  20. longdesc = models.CharField(_("long description"), max_length=255, blank=True, null=True, help_text=_("additional description of the image"))
  21. float = models.CharField(_("side"), max_length=10, blank=True, null=True, choices=FLOAT_CHOICES)
  22. def __unicode__(self):
  23. if self.alt:
  24. return self.alt[:40]
  25. elif self.image:
  26. # added if, because it raised attribute error when file wasn't defined
  27. try:
  28. return u"%s" % basename(self.image.path)
  29. except:
  30. pass
  31. return "<empty>"