Esempio n. 1
0
class Bootstrap4GridRow(CMSPlugin):
    """
    Layout > Grid: "Row" Plugin
    https://getbootstrap.com/docs/4.0/layout/grid/
    """
    vertical_alignment = models.CharField(
        verbose_name=_('Vertical alignment'),
        choices=GRID_ROW_VERTICAL_ALIGNMENT_CHOICES,
        blank=True,
        max_length=255,
        help_text=mark_safe_lazy(
            _('Read more in the <a href="{link}" target="_blank">documentation</a>.'
              ).
            format(
                link=
                'https://getbootstrap.com/docs/4.0/layout/grid/#vertical-alignment'
            )),
    )
    horizontal_alignment = models.CharField(
        verbose_name=_('Horizontal alignment'),
        choices=GRID_ROW_HORIZONTAL_ALIGNMENT_CHOICES,
        blank=True,
        max_length=255,
        help_text=mark_safe_lazy(
            _('Read more in the <a href="{link}" target="_blank">documentation</a>.'
              ).
            format(
                link=
                'https://getbootstrap.com/docs/4.0/layout/grid/#horizontal-alignment'
            )),
    )
    gutters = models.BooleanField(
        verbose_name=_('Remove gutters'),
        default=False,
        help_text=_('Removes the marginal gutters from the grid.'),
    )
    tag_type = TagTypeField()
    attributes = AttributesField()

    def __str__(self):
        return str(self.pk)

    def get_short_description(self):
        instance = self.get_plugin_instance()[0]

        if not instance:
            return ugettext('<empty>')

        column_count = len(self.child_plugin_instances or [])
        column_count_str = ungettext('(1 column)', '(%(count)i columns)',
                                     column_count) % {
                                         'count': column_count
                                     }
        # column_count_str += ' .{}'.format(
        #     ' .'.join(instance.attributes['class'].split())
        # )

        return column_count_str
Esempio n. 2
0
class Bootstrap4GridContainer(CMSPlugin):
    """
    Layout > Grid: "Container" Plugin
    https://getbootstrap.com/docs/4.0/layout/grid/
    """
    container_type = models.CharField(
        verbose_name=_('Container type'),
        choices=GRID_CONTAINER_CHOICES,
        default=GRID_CONTAINER_CHOICES[0][0],
        max_length=255,
        help_text=mark_safe_lazy(_(
            'Defines if the grid should use fixed width (<code>.container</code>) '
            'or fluid width (<code>.container-fluid</code>).'
        )),
    )
    tag_type = TagTypeField()
    attributes = AttributesField()

    def __str__(self):
        return str(self.pk)

    def get_short_description(self):
        text = ''
        for item in GRID_CONTAINER_CHOICES:
            if item[0] == self.container_type:
                text = item[1]
        return '({})'.format(text)
Esempio n. 3
0
class Bootstrap4GridRow(CMSPlugin):
    """
    Layout > Grid: "Row" Plugin
    https://getbootstrap.com/docs/4.0/layout/grid/
    """
    layout = models.CharField(
        verbose_name=_('Layout'),
        #choices=GRID_ROW_LAYOUT_CHOICES,
        blank=True,
        max_length=255,
        help_text=_('Select a layout'),
    )
    vertical_alignment = models.CharField(
        verbose_name=_('Vertical alignment'),
        choices=GRID_ROW_VERTICAL_ALIGNMENT_CHOICES,
        blank=True,
        max_length=255,
        help_text=mark_safe_lazy(
            _('Read more in the <a href="{link}" target="_blank">documentation</a>.'
              ).
            format(
                link=
                'https://getbootstrap.com/docs/4.0/layout/grid/#vertical-alignment'
            )),
    )
    horizontal_alignment = models.CharField(
        verbose_name=_('Horizontal alignment'),
        choices=GRID_ROW_HORIZONTAL_ALIGNMENT_CHOICES,
        blank=True,
        max_length=255,
        help_text=mark_safe_lazy(
            _('Read more in the <a href="{link}" target="_blank">documentation</a>.'
              ).
            format(
                link=
                'https://getbootstrap.com/docs/4.0/layout/grid/#horizontal-alignment'
            )),
    )
    full_width = models.BooleanField(
        verbose_name=_('Show Full Width'),
        default=False,
    )
    gutters = models.BooleanField(
        verbose_name=_('Remove gutters'),
        default=False,
        help_text=_('Removes the marginal gutters from the grid.'),
    )
    tag_type = TagTypeField()
    attributes = AttributesField()
    background_color = RGBColorField(verbose_name=_('Background Color'),
                                     blank=True,
                                     null=True)
    background_image = FilerImageField(verbose_name=_('Background Image'),
                                       on_delete=models.SET_NULL,
                                       null=True,
                                       blank=True,
                                       related_name='row_bg_image')
    background_svg = FilerFileField(verbose_name=_('Background SVG'),
                                    on_delete=models.SET_NULL,
                                    null=True,
                                    blank=True,
                                    related_name='+')
    background_video = models.CharField(
        verbose_name=_('Background Video'),
        blank=True,
        max_length=255,
    )
    parallax = models.BooleanField(
        verbose_name=_('Parallax'),
        default=False,
    )
    icon = Icon(verbose_name=_('Icon'), null=True, blank=True)
    title = models.CharField(
        verbose_name=_('Title'),
        null=True,
        blank=True,
        max_length=255,
    )
    display_title = models.BooleanField(
        verbose_name=_('Display Title'),
        default=False,
    )

    def __str__(self):
        return self.title or str(self.pk)

    def get_short_description(self):
        instance = self.get_plugin_instance()[0]

        if not instance:
            return ugettext('<empty>')

        column_count = len(self.child_plugin_instances or [])
        #column_count_str = ungettext(
        #'(1 col)',
        #'(%(count)i col)',
        #column_count
        #) % {'count': column_count}
        # column_count_str += ' .{}'.format(
        #     ' .'.join(instance.attributes['class'].split())
        # )

        return '(%s) %s' % (column_count, self.title or '')