class ImageTextItem(ContentItem):
    """
    A block with image + text
    """
    ALIGN_LEFT = 'left'
    ALIGN_RIGHT = 'right'
    ALIGN_CHOICES = (
        (ALIGN_LEFT, _("Left")),
        (ALIGN_RIGHT, _("Right")),
    )

    title = models.CharField(_("Title"), max_length=200)
    image = PluginImageField(_("Image"))
    align = models.CharField(_("Align"), max_length=10, choices=ALIGN_CHOICES, default=ALIGN_LEFT)
    body = PluginHtmlField(_("Body"))

    url = PluginUrlField(_("URL"), blank=True)
    url_text = models.CharField(_("Text"), max_length=200, blank=True)

    class Meta:
        verbose_name = _("Image+text")
        verbose_name_plural = _("Image+text items")

    def __str__(self):
        return self.title

    @property
    def image_css_class(self):
        if self.align == self.ALIGN_RIGHT:
            return 'image_fr'
        else:
            return 'image_fl'
Beispiel #2
0
class FilerPictureItem(ContentItem):
    ALIGN_LEFT = 'left'
    ALIGN_CENTER = 'center'
    ALIGN_RIGHT = 'right'
    ALIGN_CHOICES = (
        (ALIGN_LEFT, _("Left")),
        (ALIGN_CENTER, _("Center")),
        (ALIGN_RIGHT, _("Right")),
    )

    image = FilerImageField(verbose_name=_("image"))
    caption = models.TextField(_("caption"), blank=True)
    align = models.CharField(_("align"), max_length=10, choices=ALIGN_CHOICES, blank=True)

    url = PluginUrlField(_("URL"), blank=True)
    in_new_window = models.BooleanField(_("open in a new window"), default=False, blank=True)

    class Meta:
        verbose_name = _("Picture")
        verbose_name_plural = _("Pictures")

    def __str__(self):
        return self.caption or str(self.image)

    @property
    def align_class(self):
        if self.align == self.ALIGN_LEFT:
            return 'align-left'
        elif self.align == self.ALIGN_CENTER:
            return 'align-center'
        elif self.align == self.ALIGN_RIGHT:
            return 'align-right'
        else:
            return ''
Beispiel #3
0
class LinkItem(ContentItem):

    name = models.CharField(_("name"), max_length=256)
    url = PluginUrlField(_("URL"), null=True, blank=True)
    mailto = models.EmailField(
        _("mailto"),
        blank=True,
        null=True,
        help_text=_("An email adress has priority over a text or page link."))

    target = models.CharField(_("target"),
                              blank=True,
                              max_length=100,
                              choices=((
                                  ("", _("same window")),
                                  ("_blank", _("new window")),
                                  ("_parent", _("parent window")),
                                  ("_top", _("topmost frame")),
                              )))

    class Meta:
        verbose_name = _("Link")
        verbose_name_plural = _("Links")

    def __str__(self):
        return self.name
Beispiel #4
0
class FilerTeaserItem(ContentItem):

    title = models.CharField(_("title"), max_length=256)
    image = FilerImageField(verbose_name=_("image"), blank=True, null=True)
    url = PluginUrlField(_("URL"),
                         null=True,
                         blank=True,
                         help_text=_("If present image will be clickable."))

    description = PluginHtmlField(_("description"), blank=True, null=True)

    target = models.CharField(_("target"),
                              blank=True,
                              max_length=100,
                              choices=((
                                  ("", _("same window")),
                                  ("_blank", _("new window")),
                                  ("_parent", _("parent window")),
                                  ("_top", _("topmost frame")),
                              )))

    class Meta:
        verbose_name = _("Teaser")
        verbose_name_plural = _("Teasers")

    def __str__(self):
        return self.title
Beispiel #5
0
class PictureItem(ContentItem):
    """
    Display a picture
    """

    ALIGN_LEFT = "left"
    ALIGN_CENTER = "center"
    ALIGN_RIGHT = "right"
    ALIGN_CHOICES = (
        (ALIGN_LEFT, _("Left")),
        (ALIGN_CENTER, _("Center")),
        (ALIGN_RIGHT, _("Right")),
    )

    image = PluginImageField(_("Image"),
                             upload_to=appsettings.FLUENT_PICTURE_UPLOAD_TO)
    caption = models.TextField(_("Caption"), blank=True)
    align = models.CharField(_("Align"),
                             max_length=10,
                             choices=ALIGN_CHOICES,
                             blank=True)
    url = PluginUrlField(_("URL"), blank=True)
    in_new_window = models.BooleanField(_("Open in a new window"),
                                        default=False,
                                        blank=True)

    objects = ContentItemManager()  # Avoid Django 1.10 migrations

    class Meta:
        verbose_name = _("Picture")
        verbose_name_plural = _("Pictures")

    def __str__(self):
        return self.caption or str(self.image)

    @property
    def align_class(self):
        """
        The CSS class for alignment.
        """
        if self.align == self.ALIGN_LEFT:
            return "align-left"
        elif self.align == self.ALIGN_CENTER:
            return "align-center"
        elif self.align == self.ALIGN_RIGHT:
            return "align-right"
        else:
            return ""
Beispiel #6
0
class TeaserItem(ContentItem):

    title = models.CharField(_("title"), max_length=256)
    image = PluginImageField(
        _("image"), upload_to=appsettings.FLUENTCMS_TEASER_UPLOAD_TO, blank=True, null=True
    )
    url = PluginUrlField(
        _("URL"), null=True, blank=True, help_text=_("If present image will be clickable.")
    )
    url_title = models.CharField(_("URL title"), max_length=200, blank=True, null=True)

    description = PluginHtmlField(_("description"), blank=True, null=True)

    target = models.CharField(
        _("target"),
        blank=True,
        max_length=100,
        choices=(
            (
                ("", _("same window")),
                ("_blank", _("new window")),
                ("_parent", _("parent window")),
                ("_top", _("topmost frame")),
            )
        ),
    )

    class Meta:
        verbose_name = _("Teaser")
        verbose_name_plural = _("Teasers")

    def __str__(self):
        return self.title

    def save(self, *args, **kwargs):
        if appsettings.FLUENTCMS_TEASER_CLEAN_HTML:
            self.description = clean_html(self.description)

        # Remove unwanted tags if requested
        if appsettings.FLUENTCMS_TEASER_SANITIZE_HTML:
            self.description = sanitize_html(self.description)

        super().save(*args, **kwargs)