Example #1
0
class ModalCMSPlugin(CMSPlugin):
    identifier = models.CharField(max_length=255)
    tag_type = TagTypeField()
    attributes = AttributesField()
    dialog_attributes = AttributesField()

    def __str__(self):
        return self.identifier
Example #2
0
class Bootstrap4Blockquote(CMSPlugin):
    """
    Content > "Blockquote" Plugin
    https://getbootstrap.com/docs/4.0/content/typography/#blockquotes
    """
    quote_content = models.TextField(
        verbose_name=_('Quote'),
    )
    quote_origin = models.TextField(
        verbose_name=_('Cite'),
        blank=True,
    )
    quote_alignment = models.CharField(
        verbose_name=_('Alignment'),
        choices=ALIGN_CHOICES,
        default=ALIGN_CHOICES[0][0],
        blank=True,
        max_length=255,
    )
    attributes = AttributesField()

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

    def get_short_description(self):
        return self.quote_content
Example #3
0
class Bootstrap4Boxout(CMSPlugin):
    """
    Components > "Boxout" Plugin
    https://getbootstrap.com/docs/4.0/components/boxout/
    """
    fluid = models.BooleanField(
        verbose_name=_('Fluid'),
        default=False,
        help_text=_('Adds the .boxout-fluid class.'),
    )
    tag_type = TagTypeField()
    background_color = RGBColorField(
        verbose_name=_('Background Color'),
        blank=True,
        null=True
    )
    attributes = AttributesField()

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

    def get_short_description(self):
        text = ''
        if self.fluid:
            text = '({})'.format(_('Fluid'))
        return text
Example #4
0
class Bootstrap4Collapse(CMSPlugin):
    """
    Component > "Collapse" Plugin
    https://getbootstrap.com/docs/4.0/components/collapse/
    """
    layout = models.CharField(
        verbose_name=_('Layout'),
        blank=True,
        max_length=255,
        help_text=_('Select a layout'),
    )
    siblings = models.CharField(
        verbose_name=_('Siblings'),
        default='.card',
        max_length=255,
        help_text=_('Element to be used to create accordions.'),
    )
    tag_type = TagTypeField()
    attributes = AttributesField(excluded_keys=['id'])

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

    def get_short_description(self):
        return '(collapse-{})'.format(str(self.pk))
Example #5
0
class Bootstrap4Cta(CMSPlugin):
    """
    Components > "Cta" Plugin
    https://getbootstrap.com/docs/4.0/components/cta/
    """
    layout = models.CharField(
        verbose_name=_('Layout'),
        choices=CTA_LAYOUT_CHOICES,
        blank=True,
        max_length=255,
        help_text=_('Select a layout'),
    )
    fluid = models.BooleanField(
        verbose_name=_('Fluid'),
        default=False,
        help_text=_('Adds the .cta-fluid class.'),
    )
    tag_type = TagTypeField()
    background_color = RGBColorField(
        verbose_name=_('Background Color'),
        blank=True,
        null=True
    )
    attributes = AttributesField()

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

    def get_short_description(self):
        text = ''
        if self.fluid:
            text = '({})'.format(_('Fluid'))
        return text
Example #6
0
class Bootstrap4CollapseContainer(CMSPlugin):
    """
    Component > "Collapse Container" Plugin
    https://getbootstrap.com/docs/4.0/components/collapse/
    """
    identifier = models.SlugField(
        verbose_name=_('Unique identifier'),
        max_length=255,
        blank=False,
        help_text=_('Identifier to connect trigger with container.'),
    )
    tag_type = TagTypeField()
    attributes = AttributesField(excluded_keys=[
        'data-toggle',
        'data-target',
        'data-parent',
        'aria-expanded',
        'aria-controls',
        'role',
    ])

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

    def get_short_description(self):
        return '({})'.format(self.identifier)
Example #7
0
class Bootstrap4Badge(CMSPlugin):
    """
    Components > "Badge" Plugin
    https://getbootstrap.com/docs/4.0/components/badge/
    """
    badge_text = models.CharField(
        verbose_name=_('Badge text'),
        max_length=255,
    )
    badge_context = models.CharField(
        verbose_name=_('Context'),
        choices=COLOR_STYLE_CHOICES,
        default=COLOR_STYLE_CHOICES[0][0],
        max_length=255,
    )
    badge_pills = models.BooleanField(
        verbose_name=_('Pills style'),
        default=False,
        help_text=_('Activates the pills style.'),
    )

    attributes = AttributesField()

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

    def get_short_description(self):
        return '({})'.format(self.badge_context)
Example #8
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)
Example #9
0
class Bootstrap4ListGroupItem(CMSPlugin):
    """
    Components > "List Group Ite" Plugin
    https://getbootstrap.com/docs/4.0/components/list-group/
    """
    list_context = models.CharField(
        verbose_name=_('Context'),
        choices=COLOR_STYLE_CHOICES,
        blank=True,
        max_length=255,
    )
    list_state = models.CharField(
        verbose_name=_('State'),
        choices=LISTGROUP_STATE_CHOICES,
        blank=True,
        max_length=255,
    )
    tag_type = TagTypeField()
    attributes = AttributesField()

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

    def get_short_description(self):
        text = ''
        if self.list_context:
            text = '.list-group-item-{} '.format(self.list_context)
        if self.list_state:
            text += self.list_state
        return text
Example #10
0
class Bootstrap4GridColumn(CMSPlugin):
    """
    Layout > Grid: "Column" Plugin
    https://getbootstrap.com/docs/4.0/layout/grid/
    """
    column_type = models.CharField(
        verbose_name=_('Column type'),
        choices=GRID_COLUMN_CHOICES,
        default=GRID_COLUMN_CHOICES[0][0],
        blank=True,
        max_length=255,
    )
    column_alignment = models.CharField(
        verbose_name=_('Alignment'),
        choices=GRID_COLUMN_ALIGNMENT_CHOICES,
        blank=True,
        max_length=255,
    )
    tag_type = TagTypeField()
    attributes = AttributesField()

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

    def get_short_description(self):
        text = ''
        classes = self.get_grid_values()
        if self.xs_col:
            text += '(col-{}) '.format(self.xs_col)
        else:
            text += '(auto) '
        if self.column_type != 'col':
            text += '.{} '.format(self.column_type)
        if classes:
            text += '.{}'.format(' .'.join(self.get_grid_values()))
        return text

    def get_grid_values(self):
        classes = []
        for device in DEVICE_SIZES:
            for element in ('col', 'order', 'offset', 'ml', 'mr'):
                size = getattr(self, '{}_{}'.format(device, element))
                if isinstance(size,
                              int) and (element == 'col' or element == 'order'
                                        or element == 'offset'):
                    if device == 'xs':
                        classes.append('{}-{}'.format(element, int(size)))
                    else:
                        classes.append('{}-{}-{}'.format(
                            element, device, int(size)))
                elif size:
                    if device == 'xs':
                        classes.append('{}-{}'.format(element, 'auto'))
                    else:
                        classes.append('{}-{}-{}'.format(
                            element, device, 'auto'))

        return classes
Example #11
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
Example #12
0
class Bootstrap4GridColumn(CMSPlugin):
    """
    Layout > Grid: "Column" Plugin
    https://getbootstrap.com/docs/4.0/layout/grid/
    """
    column_type = models.CharField(
        verbose_name=_('Column type'),
        choices=GRID_COLUMN_CHOICES,
        default=GRID_COLUMN_CHOICES[0][0],
        blank=True,
        max_length=255,
    )
    column_size = IntegerRangeField(
        verbose_name=_('Column size'),
        blank=True,
        null=True,
        min_value=0,
        max_value=GRID_SIZE,
        help_text=_(
            'Nummeric value from 1 - {bound}. '
            'Spreads the columns evenly when empty.').format(bound=GRID_SIZE))
    column_alignment = models.CharField(
        verbose_name=_('Alignment'),
        choices=GRID_COLUMN_ALIGNMENT_CHOICES,
        blank=True,
        max_length=255,
    )
    tag_type = TagTypeField()
    attributes = AttributesField()

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

    def get_short_description(self):
        text = ''
        classes = self.get_grid_values()
        if self.column_size:
            text += '(col-{}) '.format(self.column_size)
        else:
            text += '(auto) '
        if self.column_type != 'col':
            text += '.{} '.format(self.column_type)
        if classes:
            text += '.{}'.format(' .'.join(self.get_grid_values()))
        return text

    def get_grid_values(self):
        classes = []
        for device in DEVICE_SIZES:
            for element in ('col', 'order', 'ml', 'mr'):
                size = getattr(self, '{}_{}'.format(device, element))
                if size and (element == 'col' or element == 'order'):
                    classes.append('{}-{}-{}'.format(element, device,
                                                     int(size)))
                elif size:
                    classes.append('{}-{}-{}'.format(element, device, 'auto'))
        return classes
Example #13
0
class Bootstrap4Blockquote(CMSPlugin):
    """
    Content > "Blockquote" Plugin
    https://getbootstrap.com/docs/4.0/content/typography/#blockquotes
    """
    quote_content = models.TextField(verbose_name=_('Quote'), )
    quote_origin_name = models.CharField(
        verbose_name=_('Name'),
        blank=True,
        max_length=255,
    )
    quote_origin_role = models.CharField(
        verbose_name=_('Role'),
        blank=True,
        max_length=255,
    )
    quote_origin_company = models.CharField(
        verbose_name=_('Company'),
        blank=True,
        max_length=255,
    )
    quote_alignment = models.CharField(
        verbose_name=_('Alignment'),
        choices=ALIGN_CHOICES,
        default=ALIGN_CHOICES[0][0],
        blank=True,
        max_length=255,
    )
    layout = models.CharField(
        verbose_name=_('Layout'),
        default='',
        blank=True,
        max_length=255,
        help_text=_('Select a layout'),
    )
    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='quote_bg_image')
    image = FilerImageField(verbose_name=_('Image'),
                            on_delete=models.SET_NULL,
                            null=True,
                            blank=True,
                            related_name='quote_image')
    attributes = AttributesField()

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

    def get_short_description(self):
        return self.quote_content
Example #14
0
class Bootstrap4Spacing(CMSPlugin):
    """
    Utilities > "Spacing" Plugin
    https://getbootstrap.com/docs/4.0/utilities/spacing/
    """
    space_property = models.CharField(
        verbose_name=_('Property'),
        choices=SPACER_PROPERTY_CHOICES,
        default=SPACER_PROPERTY_CHOICES[0][0],
        max_length=255,
    )
    space_sides = models.CharField(
        verbose_name=_('Sides'),
        choices=SPACER_SIDE_CHOICES,
        default=SPACER_SIDE_CHOICES[0][0],
        blank=True,
        max_length=255,
    )
    space_size = models.CharField(
        verbose_name=_('Size'),
        choices=SPACER_SIZE_CHOICES,
        default=SPACER_SIZE_CHOICES[0][0],
        max_length=255,
    )
    space_device = models.CharField(
        verbose_name=_('Device'),
        choices=DEVICE_CHOICES,
        blank=True,
        max_length=255,
    )
    tag_type = TagTypeField()
    attributes = AttributesField()

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

    def get_base_css_class(self):
        # Source: https://getbootstrap.com/docs/4.0/utilities/spacing/#notation
        # [...] format {property}{sides}-{size} for xs and
        # {property}{sides}-{breakpoint}-{size} for sm, md, lg, and xl.
        if not self.space_device or self.space_device == 'xs':
            template = '{property}{sides}-{size}'
        else:
            template = '{property}{sides}-{breakpoint}-{size}'

        return template.format(
            property=self.space_property,
            sides=self.space_sides,
            breakpoint=self.space_device,
            size=self.space_size
        )

    def get_short_description(self):
        return '(.{})'.format(self.get_base_css_class())
Example #15
0
class Bootstrap4MediaBody(CMSPlugin):
    """
    Layout > "Media body" Plugin
    http://getbootstrap.com/docs/4.0/layout/media-object/
    """
    tag_type = TagTypeField()
    attributes = AttributesField()

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

    def get_short_description(self):
        return ''
Example #16
0
class Bootstrap4Modal(CMSPlugin):
    """
    Components > "Modal" Plugin
    https://getbootstrap.com/docs/4.0/components/modal/
    """
    title = models.CharField(
        verbose_name=_('Title'),
        null=True,
        blank=True,
        max_length=255,
    )
    modal_id = models.CharField(
        verbose_name=_('Modal ID'),
        null=False,
        blank=True,
        max_length=255,
    )
    layout = models.CharField(
        verbose_name=_('Layout'),
        blank=True,
        max_length=255,
        help_text=_('Select a layout'),
    )
    percentage_scrolled = models.CharField(
        verbose_name=_('Percentage Scrolled'),
        blank=True,
        default='',
        max_length=255,
        choices=PERSENTAGES,
    )
    seconds_passed = models.PositiveSmallIntegerField(
        verbose_name=_('Seconds Passed'),
        blank=True,
        null=True,
    )
    cookie_settings = models.CharField(
        verbose_name=_('Cookie settings'),
        blank=True,
        default='',
        max_length=255,
        choices=COOKIE_SETTINGS,
    )
    exit_intent = models.BooleanField(
        verbose_name=_('Exit intent'),
        default=False,
    )
    attributes = AttributesField()

    def __str__(self):
        return str(self.pk)
Example #17
0
class Bootstrap4Tab(CMSPlugin):
    """
    Components > "Navs - Tab" Plugin
    https://getbootstrap.com/docs/4.0/components/navs/
    """
    template = models.CharField(
        verbose_name=_('Template'),
        choices=TAB_TEMPLATE_CHOICES,
        default=TAB_TEMPLATE_CHOICES[0][0],
        max_length=255,
        help_text=_(
            'This is the template that will be used for the component.'),
    )
    tab_type = models.CharField(
        verbose_name=_('Type'),
        choices=TAB_TYPE_CHOICES,
        default=TAB_TYPE_CHOICES[0][0],
        max_length=255,
    )
    tab_alignment = models.CharField(
        verbose_name=_('Alignment'),
        choices=TAB_ALIGNMENT_CHOICES,
        blank=True,
        max_length=255,
    )
    tab_index = models.PositiveIntegerField(
        verbose_name=_('Index'),
        null=True,
        blank=True,
        help_text=_('Index of element to open on page load starting at 1.'),
    )
    tab_effect = models.CharField(
        verbose_name=_('Animation effect'),
        choices=TAB_EFFECT_CHOICES,
        blank=True,
        max_length=255,
    )
    tag_type = TagTypeField()
    attributes = AttributesField()

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

    def get_short_description(self):
        text = '({})'.format(self.tab_type)

        if self.tab_alignment:
            text += ' .{}'.format(self.tab_alignment)
        return text
Example #18
0
class Bootstrap4Card(CMSPlugin):
    """
    Components > "Card" Plugin
    https://getbootstrap.com/docs/4.0/components/card/
    """
    card_type = models.CharField(
        verbose_name=_('Card type'),
        choices=CARD_TYPE_CHOICES,
        default=CARD_TYPE_CHOICES[0][0],
        max_length=255,
    )
    card_context = models.CharField(
        verbose_name=_('Background context'),
        choices=CARD_COLOR_STYLE_CHOICES,
        blank=True,
        max_length=255,
    )
    card_alignment = models.CharField(
        verbose_name=_('Alignment'),
        choices=CARD_ALIGNMENT_CHOICES,
        blank=True,
        max_length=255,
    )
    card_outline = models.BooleanField(
        verbose_name=_('Outline'),
        default=False,
        help_text=_('Uses the border context instead of the background.'),
    )
    card_text_color = models.CharField(
        verbose_name=_('Text context'),
        choices=CARD_TEXT_STYLES,
        blank=True,
        max_length=255,
    )
    tag_type = TagTypeField()
    attributes = AttributesField()

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

    def get_short_description(self):
        text = '({})'.format(self.card_type)
        if self.card_context and self.card_outline:
            text += ' .border-{}'.format(self.card_context)
        elif self.card_context:
            text += ' .bg-{}'.format(self.card_context)
        if self.card_alignment:
            text += ' .{}'.format(self.card_alignment)
        return text
Example #19
0
class Bootstrap4TabItem(CMSPlugin):
    """
    Components > "Navs - Tab Item" Plugin
    https://getbootstrap.com/docs/4.0/components/navs/
    """
    tab_title = models.CharField(
        verbose_name=_('Tab title'),
        max_length=255,
    )
    tag_type = TagTypeField()
    attributes = AttributesField()

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

    def get_short_description(self):
        return self.tab_title
Example #20
0
class Bootstrap4Spacing(CMSPlugin):
    """
    Utilities > "Spacing" Plugin
    https://getbootstrap.com/docs/4.0/utilities/spacing/
    """
    space_property = models.CharField(
        verbose_name=_('Property'),
        choices=SPACER_PROPERTY_CHOICES,
        default=SPACER_PROPERTY_CHOICES[0][0],
        max_length=255,
    )
    space_sides = models.CharField(
        verbose_name=_('Sides'),
        choices=SPACER_SIDE_CHOICES,
        default=SPACER_SIDE_CHOICES[0][0],
        blank=True,
        max_length=255,
    )
    space_size = models.CharField(
        verbose_name=_('Size'),
        choices=SPACER_SIZE_CHOICES,
        default=SPACER_SIZE_CHOICES[0][0],
        max_length=255,
    )
    space_device = models.CharField(
        verbose_name=_('Device'),
        choices=DEVICE_CHOICES,
        blank=True,
        max_length=255,
    )
    tag_type = TagTypeField()
    attributes = AttributesField()

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

    def get_short_description(self):
        text = self.space_property
        if self.space_sides:
            text += self.space_sides
        if self.space_device:
            text += '-{}'.format(self.space_device)
        text += '-{}'.format(self.space_size)
        return '(.{})'.format(text)
Example #21
0
class Bootstrap4Code(CMSPlugin):
    """
    Content > "Code" Plugin
    https://getbootstrap.com/docs/4.0/content/code/
    """
    code_content = models.TextField(verbose_name=_('Code'), )
    tag_type = models.CharField(
        verbose_name=_('Code type'),
        choices=CODE_TYPE_CHOICES,
        default=CODE_TYPE_CHOICES[0][0],
        max_length=255,
    )
    attributes = AttributesField()

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

    def get_short_description(self):
        return '<{}>'.format(self.tag_type)
Example #22
0
class Bootstrap4CardInner(CMSPlugin):
    """
    Components > "Card - Inner" Plugin (Header, Footer, Body)
    https://getbootstrap.com/docs/4.0/components/card/
    """
    inner_type = models.CharField(
        verbose_name=_('Inner type'),
        choices=CARD_INNER_TYPE_CHOICES,
        default=CARD_INNER_TYPE_CHOICES[0][0],
        max_length=255,
        help_text=_('Define the structure of the plugin.'),
    )
    tag_type = TagTypeField()
    attributes = AttributesField()

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

    def get_short_description(self):
        return '({})'.format(self.inner_type)
Example #23
0
class Bootstrap4ListGroup(CMSPlugin):
    """
    Components > "List Group" Plugin
    https://getbootstrap.com/docs/4.0/components/list-group/
    """
    list_group_flush = models.BooleanField(
        verbose_name=_('List group flush'),
        default=False,
        help_text=_(
            'Create lists of content in a card with a flush list group.'))
    tag_type = TagTypeField()
    attributes = AttributesField()

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

    def get_short_description(self):
        text = ''
        if self.list_group_flush:
            text += '.list-group-flush'
        return text
Example #24
0
class Bootstrap4Jumbotron(CMSPlugin):
    """
    Components > "Jumbotron" Plugin
    https://getbootstrap.com/docs/4.0/components/jumbotron/
    """
    fluid = models.BooleanField(
        verbose_name=_('Fluid'),
        default=False,
        help_text=_('Adds the .jumbotron-fluid class.'),
    )
    tag_type = TagTypeField()
    attributes = AttributesField()

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

    def get_short_description(self):
        text = ''
        if self.fluid:
            text = '({})'.format(_('Fluid'))
        return text
Example #25
0
class Bootstrap4Figure(CMSPlugin):
    """
    Content > "Figure" Plugin
    https://getbootstrap.com/docs/4.0/content/figures/
    """
    figure_caption = models.CharField(
        verbose_name=_('Caption'),
        max_length=255,
    )
    figure_alignment = models.CharField(
        verbose_name=_('Alignment'),
        choices=ALIGN_CHOICES,
        default=ALIGN_CHOICES[0][0],
        blank=True,
        max_length=255,
    )
    attributes = AttributesField()

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

    def get_short_description(self):
        return self.figure_caption
Example #26
0
class Bootstrap4Alerts(CMSPlugin):
    """
    Components > "Alerts" Plugin
    https://getbootstrap.com/docs/4.0/components/alerts/
    """
    alert_context = models.CharField(
        verbose_name=_('Context'),
        choices=COLOR_STYLE_CHOICES,
        default=COLOR_STYLE_CHOICES[0][0],
        max_length=255,
    )
    alert_dismissable = models.BooleanField(
        verbose_name=_('Dismissable'),
        default=False,
        help_text=_('Allows the alert to be closed.'),
    )
    tag_type = TagTypeField()
    attributes = AttributesField()

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

    def get_short_description(self):
        return '({})'.format(self.alert_context)
Example #27
0
 def test_attributes_field(self):
     field = AttributesField()
     self.assertEqual(field.verbose_name, "Attributes")
     self.assertEqual(field.blank, True)
Example #28
0
class Bootstrap4GridColumn(CMSPlugin):
    """
    Layout > Grid: "Column" Plugin
    https://getbootstrap.com/docs/4.0/layout/grid/
    """
    layout = models.CharField(
        verbose_name=_('Layout'),
        #choices=GRID_COL_LAYOUT_CHOICES,
        blank=True,
        max_length=255,
        help_text=_('Select a layout'),
    )
    column_type = models.CharField(
        verbose_name=_('Column type'),
        choices=GRID_COLUMN_CHOICES,
        default=GRID_COLUMN_CHOICES[0][0],
        blank=True,
        max_length=255,
    )
    column_size = IntegerRangeField(
        verbose_name=_('Column size'),
        blank=True,
        null=True,
        min_value=0,
        max_value=GRID_SIZE,
        help_text=_(
            'Nummeric value from 1 - {bound}. '
            'Spreads the columns evenly when empty.').format(bound=GRID_SIZE))
    column_alignment = models.CharField(
        verbose_name=_('Alignment'),
        choices=GRID_COLUMN_ALIGNMENT_CHOICES,
        blank=True,
        max_length=255,
    )
    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='col_bg_image')
    background_svg = FilerFileField(verbose_name=_('Background SVG'),
                                    on_delete=models.SET_NULL,
                                    null=True,
                                    blank=True,
                                    related_name='+')
    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 str(self.pk)

    def get_short_description(self):
        text = ''
        classes = self.get_grid_values()
        if self.column_size:
            text += '(col-{}) '.format(self.column_size)
        else:
            text += '(auto) '
        if self.column_type != 'col':
            text += '.{} '.format(self.column_type)
        if classes:
            text += '.{}'.format(' .'.join(self.get_grid_values()))
        return text

    def get_grid_values(self):
        classes = []
        hide = True
        for device in DEVICE_SIZES:
            for element in ('col', 'order', 'ml', 'mr', 'hide'):
                size = getattr(self, '{}_{}'.format(device, element))
                if size:
                    if element == 'hide':
                        if device == 'xs':
                            classes.append('{}-{}'.format('d', 'none'))
                        else:
                            classes.append('{}-{}-{}'.format(
                                'd', device, 'none'))
                        hide = True
                    elif element == 'col':
                        classes.append('{}-{}-{}'.format(
                            element, device, int(size)))
                    elif element == 'order':
                        if device == 'xs':
                            classes.append('{}-{}'.format(element, int(size)))
                        else:
                            classes.append('{}-{}-{}'.format(
                                element, device, int(size)))
                    else:
                        classes.append('{}-{}-{}'.format(
                            element, device, 'auto'))
                else:
                    if hide and element == 'hide':
                        if device == 'xs':
                            classes.append('{}-{}'.format('d', 'block'))
                        else:
                            classes.append('{}-{}-{}'.format(
                                'd', device, 'block'))
                        hide = False

        return classes
Example #29
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 '')
Example #30
0
class Bootstrap4Carousel(CMSPlugin):
    """
    Components > "Carousel" Plugin
    https://getbootstrap.com/docs/4.0/components/carousel/
    """
    carousel_style = models.CharField(
        verbose_name=_('Template'),
        choices=CAROUSEL_TEMPLATE_CHOICES,
        default=CAROUSEL_TEMPLATE_CHOICES[0][0],
        max_length=255,
        help_text=_(
            'This is the template that will be used for the component.'),
    )
    carousel_interval = models.IntegerField(
        verbose_name=_('Interval'),
        default=5000,
        help_text=_(
            'The amount of time to delay between automatically cycling '
            'an item. If false, carousel will not automatically cycle.'),
    )
    carousel_controls = models.BooleanField(
        verbose_name=_('Controls'),
        default=True,
        help_text=_('Adding in the previous and next controls.'),
    )
    carousel_indicators = models.BooleanField(
        verbose_name=_('Indicators'),
        default=True,
        help_text=_('Adding in the indicators to the carousel.'),
    )
    carousel_keyboard = models.BooleanField(
        verbose_name=_('Keyboard'),
        default=True,
        help_text=_('Whether the carousel should react to keyboard events.'),
    )
    carousel_pause = models.CharField(
        verbose_name=_('Pause'),
        choices=CAROUSEL_PAUSE_CHOICES,
        default=CAROUSEL_PAUSE_CHOICES[0][0],
        max_length=255,
        help_text=_(
            'If set to "hover", pauses the cycling of the carousel on '
            '"mouseenter" and resumes the cycling of the carousel on '
            '"mouseleave". If set to "false", hovering over the carousel '
            'won\'t pause it.'))
    carousel_ride = models.CharField(
        verbose_name=_('Ride'),
        choices=CAROUSEL_RIDE_CHOICES,
        default=CAROUSEL_RIDE_CHOICES[0][0],
        max_length=255,
        help_text=_(
            'Autoplays the carousel after the user manually cycles the '
            'first item. If "carousel", autoplays the carousel on load.'),
    )
    carousel_wrap = models.BooleanField(
        verbose_name=_('Wrap'),
        default=True,
        help_text=_('Whether the carousel should cycle continuously or have '
                    'hard stops.'),
    )
    carousel_aspect_ratio = models.CharField(
        verbose_name=_('Aspect ratio'),
        choices=CAROUSEL_ASPECT_RATIO_CHOICES,
        blank=True,
        default='',
        max_length=255,
        help_text=_('Determines width and height of the image '
                    'according to the selected ratio.'),
    )
    tag_type = TagTypeField()
    attributes = AttributesField(excluded_keys=[
        'id', 'data-interval', 'data-keyboard', 'data-pause', 'data-ride',
        'data-wrap'
    ], )

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

    def get_short_description(self):
        text = '({})'.format(self.carousel_style)
        text += ' {}: {}'.format(_('Interval'), self.carousel_interval)
        text += ', {}: {}'.format(_('Controls'), self.carousel_controls)
        text += ', {}: {}'.format(_('Indicators'), self.carousel_indicators)
        text += ', {}: {}'.format(_('Keyboard'), self.carousel_keyboard)
        text += ', {}: {}'.format(_('Pause'), self.carousel_pause)
        text += ', {}: {}'.format(_('Ride'), self.carousel_ride)
        text += '{}: {}'.format(_('Wrap'), self.carousel_wrap)
        return text