コード例 #1
0
 def test_concat_classes(self):
     classes = ['class1 class2', 'class3']
     self.assertEqual(
         concat_classes(classes),
         'class1 class2 class3',
     )
     classes = []
     self.assertEqual(concat_classes(classes), '')
コード例 #2
0
ファイル: cms_plugins.py プロジェクト: Rupeshroc/djangocms
    def render(self, context, instance, placeholder):
        classes = concat_classes([instance.inner_type] + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super().render(context, instance, placeholder)
コード例 #3
0
    def render(self, context, instance, placeholder):
        parent = instance.parent.get_plugin_instance()[0]
        width = float(context.get('width') or CAROUSEL_DEFAULT_SIZE[0])
        height = float(context.get('height') or CAROUSEL_DEFAULT_SIZE[1])

        if parent.carousel_aspect_ratio:
            aspect_width, aspect_height = tuple(
                [int(i) for i in parent.carousel_aspect_ratio.split('x')]
            )
            height = width * aspect_height / aspect_width

        link_classes = ['carousel-item']
        if instance.position == 0:
            link_classes.append('active')
        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        context['instance'] = instance
        context['link'] = instance.get_link()
        context['options'] = {
            'crop': 10,
            'size': (width, height),
            'upscale': True
        }
        return context
コード例 #4
0
    def render(self, context, instance, placeholder):
        link_classes = []
        if instance.link_context:
            if instance.link_type == 'link':
                link_classes.append('text-{}'.format(instance.link_context))
            else:
                link_classes.append('btn')
                if not instance.link_outline:
                    link_classes.append('btn-{}'.format(instance.link_context))
                else:
                    link_classes.append('btn-outline-{}'.format(
                        instance.link_context))
        if instance.link_size:
            link_classes.append(instance.link_size)
        if instance.link_block:
            link_classes.append('btn-block')
        if instance.link_alignment:
            link_classes.append(instance.link_alignment)

        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        # Check if (Aldryn) Google Tag Manager (GTM) is installed, and pass to template
        if 'aldryn_google_tag_manager' in settings.INSTALLED_APPS:
            context['gtm_installed'] = True

        return super(Bootstrap4LinkPlugin,
                     self).render(context, instance, placeholder)
コード例 #5
0
    def render(self, context, instance, placeholder):
        column = ''
        classes = instance.get_grid_values()

        if instance.column_size:
            column = 'col-{}'.format(instance.column_size)
        if classes:
            column += ' {}'.format(' '.join(cls for cls in classes if cls))

        attr_classes = concat_classes([
            instance.column_type,
            column,
            instance.column_alignment,
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = attr_classes

        styles = instance.attributes.get('style', '').split(' ')
        background = []
        if instance.background_color:
            background.append(instance.background_color)
        if instance.background_image:
            background.append('url(%s)' % instance.background_image.url)
        if background:
            styles.append('background: %s;' % ' '.join(background))
        instance.attributes['style'] = ' '.join(styles)

        return super(Bootstrap4GridColumnPlugin,
                     self).render(context, instance, placeholder)
コード例 #6
0
    def render(self, context, instance, placeholder):
        classes = concat_classes(
            [
                "modal fade",
                instance.attributes.get("class"),
            ]
        )
        instance.attributes["class"] = classes
        dialog_classes = concat_classes(
            [
                "modal-dialog",
                instance.dialog_attributes.get("class"),
            ]
        )
        instance.dialog_attributes["class"] = dialog_classes

        return super().render(context, instance, placeholder)
コード例 #7
0
ファイル: cms_plugins.py プロジェクト: Rupeshroc/djangocms
    def render(self, context, instance, placeholder):
        classes = concat_classes([
            'media-body',
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super().render(context, instance, placeholder)
コード例 #8
0
    def render(self, context, instance, placeholder):
        instance.attributes['class'] = concat_classes([
            instance.get_base_css_class(),
            instance.attributes.get('class'),
        ])

        return super().render(
            context, instance, placeholder
        )
コード例 #9
0
    def render(self, context, instance, placeholder):
        classes = concat_classes([
            instance.container_type,
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super(Bootstrap4GridContainerPlugin,
                     self).render(context, instance, placeholder)
コード例 #10
0
    def render(self, context, instance, placeholder):
        classes = concat_classes([
            'figure',
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super(Bootstrap4FigurePlugin,
                     self).render(context, instance, placeholder)
コード例 #11
0
ファイル: cms_plugins.py プロジェクト: Rupeshroc/djangocms
    def render(self, context, instance, placeholder):
        link_classes = ['blockquote']
        if instance.quote_alignment:
            link_classes.append(instance.quote_alignment)
        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super().render(context, instance, placeholder)
コード例 #12
0
    def render(self, context, instance, placeholder):
        link_classes = ['carousel', 'slide']

        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super(Bootstrap4CarouselPlugin,
                     self).render(context, instance, placeholder)
コード例 #13
0
ファイル: cms_plugins.py プロジェクト: Rupeshroc/djangocms
    def render(self, context, instance, placeholder):
        link_classes = ['list-group']
        if instance.list_group_flush:
            link_classes.append('list-group-flush')

        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super().render(context, instance, placeholder)
コード例 #14
0
    def render(self, context, instance, placeholder):
        link_classes = ['alert']
        link_classes.append('alert-{}'.format(instance.alert_context))

        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super(Bootstrap4AlertsPlugin,
                     self).render(context, instance, placeholder)
コード例 #15
0
    def render(self, context, instance, placeholder):
        link_classes = ['jumbotron']
        if instance.fluid:
            link_classes.append('jumbotron-fluid')

        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super(Bootstrap4JumbotronPlugin,
                     self).render(context, instance, placeholder)
コード例 #16
0
ファイル: cms_plugins.py プロジェクト: Rupeshroc/djangocms
    def render(self, context, instance, placeholder):
        gutter = 'no-gutters' if instance.gutters else ''
        classes = concat_classes([
            'row',
            instance.vertical_alignment,
            instance.horizontal_alignment,
            gutter,
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super().render(context, instance, placeholder)
コード例 #17
0
    def render(self, context, instance, placeholder):
        link_classes = []
        if instance.inner_type:
            link_classes.append(instance.inner_type)

        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super(Bootstrap4CardInnerPlugin,
                     self).render(context, instance, placeholder)
コード例 #18
0
    def render(self, context, instance, placeholder):
        link_classes = ['badge']
        if instance.badge_pills:
            link_classes.append('badge-pill')
        link_classes.append('badge-{}'.format(instance.badge_context))

        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super(Bootstrap4BadgePlugin, self).render(
            context, instance, placeholder
        )
コード例 #19
0
ファイル: cms_plugins.py プロジェクト: Rupeshroc/djangocms
    def render(self, context, instance, placeholder):
        link_classes = ['list-group-item']
        if instance.list_context:
            link_classes.append('list-group-item-{}'.format(
                instance.list_context))
        if instance.list_state:
            link_classes.append(instance.list_state)

        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super().render(context, instance, placeholder)
コード例 #20
0
    def render(self, context, instance, placeholder):
        gutter = 'no-gutters' if instance.gutters else ''
        classes = concat_classes([
            'row',
            instance.vertical_alignment,
            instance.horizontal_alignment,
            gutter,
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes
        self.append_background_image(instance)

        return super(Bootstrap4GridRowPlugin,
                     self).render(context, instance, placeholder)
コード例 #21
0
ファイル: cms_plugins.py プロジェクト: Rupeshroc/djangocms
    def render(self, context, instance, placeholder):
        link_classes = []
        if instance.picture_fluid:
            link_classes.append('img-fluid')
        if instance.picture_rounded:
            link_classes.append('rounded')
        if instance.picture_thumbnail:
            link_classes.append('img-thumbnail')

        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super().render(context, instance, placeholder)
コード例 #22
0
    def render(self, context, instance, placeholder):
        link_classes = ['boxout']
        if instance.fluid:
            link_classes.append('boxout-fluid')

        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes
        if instance.background_color:
            instance.attributes[
                'style'] = 'background: %s;' % instance.background_color

        return super(Bootstrap4BoxoutPlugin,
                     self).render(context, instance, placeholder)
コード例 #23
0
    def render(self, context, instance, placeholder):
        spacing = '{}'.format(instance.space_property)
        if instance.space_sides:
            spacing += '{}'.format(instance.space_sides)
        if instance.space_device:
            spacing += '-{}'.format(instance.space_device)
        spacing += '-{}'.format(instance.space_size)

        classes = concat_classes([
            spacing,
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super(Bootstrap4SpacingPlugin,
                     self).render(context, instance, placeholder)
コード例 #24
0
ファイル: cms_plugins.py プロジェクト: Rupeshroc/djangocms
    def render(self, context, instance, placeholder):
        column = ''
        classes = instance.get_grid_values()

        if classes:
            column += '{}'.format(' '.join(cls for cls in classes if cls))

        attr_classes = concat_classes([
            instance.column_type,
            column,
            instance.column_alignment,
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = attr_classes

        return super().render(context, instance, placeholder)
コード例 #25
0
    def render(self, context, instance, placeholder):
        link_classes = ['boxout']
        if instance.full_width:
            link_classes.append('full-width')
        if instance.fluid:
            link_classes.append('boxout-fluid')
        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes
        styles = instance.attributes.get('style', '').split(' ')
        if instance.background_color:
            styles.append('background: %s;' % instance.background_color)
        instance.attributes['style'] = ' '.join(styles)

        return super(Bootstrap4BoxoutPlugin,
                     self).render(context, instance, placeholder)
コード例 #26
0
ファイル: cms_plugins.py プロジェクト: Rupeshroc/djangocms
    def render(self, context, instance, placeholder):
        link_classes = [instance.card_type]
        if instance.card_context and instance.card_outline:
            link_classes.append('border-{}'.format(instance.card_context))
        elif instance.card_context:
            link_classes.append('bg-{}'.format(instance.card_context))
        if instance.card_alignment:
            link_classes.append(instance.card_alignment)
        if instance.card_text_color:
            link_classes.append('text-{}'.format(instance.card_text_color))

        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        return super().render(context, instance, placeholder)
コード例 #27
0
    def render(self, context, instance, placeholder):
        gutter = 'no-gutters' if instance.gutters else ''
        classes = concat_classes([
            'row',
            instance.vertical_alignment,
            instance.horizontal_alignment,
            gutter,
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes
        if instance.background_color or instance.background_image:
            color_str = ' %s' % instance.background_color if instance.background_color else ''
            img_str = ' url(%s)' % instance.background_image.url if instance.background_image else ''
            instance.attributes['style'] = 'background:%s%s;' % (color_str,
                                                                 img_str)

        return super(Bootstrap4GridRowPlugin,
                     self).render(context, instance, placeholder)
コード例 #28
0
    def render(self, context, instance, placeholder):
        column = ''
        classes = instance.get_grid_values()

        if classes:
            column += '{}'.format(' '.join(cls for cls in classes if cls))

        attr_classes = concat_classes([
            instance.column_type,
            column,
            instance.column_alignment,
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = attr_classes
        self.append_background_image(instance)

        return super(Bootstrap4GridColumnPlugin,
                     self).render(context, instance, placeholder)
コード例 #29
0
    def render(self, context, instance, placeholder):
        link_classes = []
        if instance.picture_fluid:
            link_classes.append('img-fluid')
        if instance.picture_rounded:
            link_classes.append('rounded')
        if instance.picture_thumbnail:
            link_classes.append('img-thumbnail')

        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        # Check if (Aldryn) Google Tag Manager (GTM) is installed, and pass to template
        if 'aldryn_google_tag_manager' in settings.INSTALLED_APPS:
            context['gtm_installed'] = True

        return super(Bootstrap4PicturePlugin,
                     self).render(context, instance, placeholder)
コード例 #30
0
    def render(self, context, instance, placeholder):
        link_classes = ['blockquote']
        if instance.quote_alignment:
            link_classes.append(instance.quote_alignment)
        classes = concat_classes(link_classes + [
            instance.attributes.get('class'),
        ])
        instance.attributes['class'] = classes

        styles = instance.attributes.get('style', '').split(' ')
        background = []
        if instance.background_color:
            background.append(instance.background_color)
        if instance.background_image:
            background.append('url(%s)' % instance.background_image.url)
        if background:
            styles.append('background: %s;' % ' '.join(background))
        instance.attributes['style'] = ' '.join(styles)

        return super(Bootstrap4BlockquotePlugin,
                     self).render(context, instance, placeholder)