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
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
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
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)
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)
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))
class ModalCMSPlugin(CMSPlugin): identifier = models.CharField(max_length=255) tag_type = TagTypeField() attributes = AttributesField() dialog_attributes = AttributesField() def __str__(self): return self.identifier
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
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
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
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())
class Bootstrap4CarouselSlide(AbstractLink): """ Components > "Slide" Plugin https://getbootstrap.com/docs/4.0/components/carousel/ """ carousel_image = FilerImageField( verbose_name=_('Slide image'), blank=False, null=True, on_delete=models.SET_NULL, related_name='+', ) carousel_content = HTMLField( verbose_name=_('Content'), blank=True, default='', help_text=_('Content may also be added using child plugins.'), ) tag_type = TagTypeField() def __str__(self): return str(self.pk) def clean(self): super(AbstractLink, self).clean() def get_link(self): return AbstractLink.get_link(self) def get_short_description(self): image_text = content_text = '' if self.carousel_image_id: if self.carousel_image.name: image_text = self.carousel_image.name elif self.carousel_image.original_filename \ and os.path.split(self.carousel_image.original_filename)[1]: image_text = os.path.split( self.carousel_image.original_filename)[1] else: image_text = 'Image' if self.carousel_content: text = strip_tags(self.carousel_content).strip() if len(text) > 100: content_text = '{}...'.format(text[:100]) else: content_text = '{}'.format(text) if image_text and content_text: return '{} ({})'.format(image_text, content_text) else: return image_text or content_text
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 ''
def test_tag_type_field(self): field = TagTypeField() self.assertEqual(field.verbose_name, "Tag type") self.assertEqual(field.choices, (('div', 'div'), ('section', 'section'), ('article', 'article'), ('header', 'header'), ('footer', 'footer'), ('aside', 'aside'))) self.assertEqual(field.default, "div") self.assertEqual(field.max_length, 255) self.assertEqual( field.help_text, "Select the HTML tag to be used.", )
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
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
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
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)
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)
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
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
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)
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
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 '')
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
class Bootstrap4CarouselSlide(AbstractLink, CMSPlugin): carousel_style = models.CharField( verbose_name=_('Template'), default='default', max_length=255, help_text=_( 'This is the template that will be used for the component.'), ) carousel_image = FilerImageField( verbose_name=_('Slide image'), blank=True, null=True, on_delete=models.SET_NULL, related_name='+', ) carousel_video = FilerFileField( verbose_name=_('Slide video background'), blank=True, null=True, on_delete=models.SET_NULL, related_name='+', help_text=_('Use MP4 videos'), ) carousel_video_url = models.CharField( verbose_name=_('Slide video background url'), blank=True, null=True, max_length=255) animate_title = models.BooleanField( verbose_name=_('Animate Title'), default=False, ) title = models.CharField(verbose_name=_('title'), max_length=255, blank=True, null=True) carousel_content = HTMLField( verbose_name=_('Content'), blank=True, default='', help_text=_('Content may also be added using child plugins.'), ) background_color = RGBColorField(verbose_name=_('Background Color'), blank=True, null=True) link = models.CharField(verbose_name=_('Link'), blank=True, max_length=2040) tag_type = TagTypeField() def __str__(self): return str(self.pk) def clean(self): super(AbstractLink, self).clean() def get_link(self): return AbstractLink.get_link(self) def get_short_description(self): image_text = content_text = '' if self.carousel_image_id: if self.carousel_image.name: image_text = self.carousel_image.name elif self.carousel_image.original_filename \ and os.path.split(self.carousel_image.original_filename)[1]: image_text = os.path.split( self.carousel_image.original_filename)[1] else: image_text = 'Image' if self.carousel_content: text = strip_tags(self.carousel_content).strip() if len(text) > 100: content_text = '{}...'.format(text[:100]) else: content_text = '{}'.format(text) if image_text and content_text: return '{} ({})'.format(image_text, content_text) else: return image_text or content_text