Esempio n. 1
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
Esempio n. 2
0
class RelatedServicesPlugin(CMSPlugin):

    # NOTE: This one does NOT subclass NewsBlogCMSPlugin. This is because this
    # plugin can really only be placed on the article detail view in an apphook.
    cmsplugin_ptr = models.OneToOneField(
        CMSPlugin, on_delete=models.CASCADE, related_name='+', parent_link=True)

    title = models.CharField(max_length=255, blank=True, verbose_name=_('Title'))
    icon = Icon(blank=False, default='')
    image = FilerImageField(on_delete=models.SET_NULL, null=True, blank=True, related_name='+')
    count = models.PositiveSmallIntegerField(verbose_name=_('Number services'))
    layout = models.CharField(max_length=30, verbose_name=_('layout'))
    background_color = RGBColorField(verbose_name=_('Background Color'),
        blank=True, null=True)
    full_screen = models.BooleanField(_('Show full screen'), default=False)
    related_services = SortedManyToManyField('js_services.Service', verbose_name=_('related services'), blank=True, symmetrical=False)
    related_sections = SortedManyToManyField(ServicesConfig, verbose_name=_('related sections'), blank=True, symmetrical=False)
    related_people = SortedManyToManyField(Person, verbose_name=_('key people'), blank=True, symmetrical=False)
    related_categories = SortedManyToManyField('aldryn_categories.Category', verbose_name=_('related categories'), blank=True, symmetrical=False)

    def copy_relations(self, oldinstance):
        self.related_services.set(oldinstance.related_services.all())
        self.related_sections.set(oldinstance.related_sections.all())
        self.related_people.set(oldinstance.related_people.all())
        self.related_categories.set(oldinstance.related_categories.all())
        if IS_THERE_COMPANIES:
            self.related_companies.set(oldinstance.related_companies.all())

    def __str__(self):
        return str(self.pk)
Esempio n. 3
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
Esempio n. 4
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
Esempio n. 5
0
class ShowcaseSection(CMSPlugin):
    title = models.CharField(_('Anchor title'), max_length=255, blank=True, null=True)
    background_color = RGBColorField(_('Background Color'), blank=True, null=True)
    background_image = FilerImageField(verbose_name=_('Background Image'), blank=True, null=True, on_delete=models.SET_NULL, related_name='+')
    background_video_url = models.CharField(_('Background Video URL'), max_length=255, blank=True, null=True)
    layout = models.CharField(_('layout'), max_length=60, default='', blank=True)
    attributes = AttributesField()

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

    def get_id(self):
        return slugify(self.title or 'section %s' % self.pk)
Esempio n. 6
0
class Session(CMSPlugin):
    start_time = models.CharField(
        max_length=255,
        verbose_name=_('Start Time'),
    )
    end_time = models.CharField(
        max_length=255,
        verbose_name=_('End Time'),
    )
    title = models.CharField(
        max_length=255,
        verbose_name=_('Title'),
    )
    session_type = models.CharField(max_length=255,
                                    verbose_name=_('Type'),
                                    blank=True)
    description = HTMLField(verbose_name=_('Description'),
                            default='',
                            blank=True)
    speakers_list_title = models.CharField(
        max_length=255,
        blank=True,
        verbose_name=_('Speakers List Title Type 1'))
    speakers_list = SortedManyToManyField(
        'js_events.Speaker',
        verbose_name=_('Speakers Type 1'),
        blank=True,
        related_name='sessions',
    )
    speakers_list_title2 = models.CharField(
        max_length=255,
        blank=True,
        verbose_name=_('Speakers List Title Type 2'))
    speakers_list2 = SortedManyToManyField(
        'js_events.Speaker',
        verbose_name=_('Speakers Type 2'),
        blank=True,
        related_name='sessions2',
    )
    backgrond_color = RGBColorField(
        verbose_name=_('Backgrond color'),
        blank=True,
        null=True,
    )

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

    def copy_relations(self, oldinstance):
        self.speakers_list = oldinstance.speakers_list.all()
        self.speakers_list2 = oldinstance.speakers_list2.all()
Esempio n. 7
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()
    background_color = RGBColorField(
        verbose_name=_('Background Color'),
        blank=True,
        null=True
    )
    background_image = FilerImageField(
        verbose_name=_('Background Image'),
        null=True,
        blank=True,
        related_name='row_bg_image'
    )
    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 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. 8
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()
    background_color = RGBColorField(
        verbose_name=_('Background Color'),
        blank=True,
        null=True
    )
    background_image = FilerImageField(
        verbose_name=_('Background Image'),
        null=True,
        blank=True,
        related_name='col_bg_image'
    )
    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 = []
        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
Esempio n. 9
0
class Bootstrap4Tab(CMSPlugin):
    """
    Components > "Navs - Tab" Plugin
    https://getbootstrap.com/docs/4.0/components/navs/
    """
    title = models.CharField(
        verbose_name=_('Title'),
        max_length=255,
        null=True,
        blank=True,
    )
    show_title = models.BooleanField(
        verbose_name=_('Show title'),
        default=False,
    )
    full_width = models.BooleanField(
        verbose_name=_('Full Width'),
        default=False,
    )
    background_color = RGBColorField(verbose_name=_('Background Color'),
                                     blank=True,
                                     null=True)
    tab_style = 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 self.title or str(self.pk)

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

        if self.tab_alignment:
            text += '.{}'.format(self.tab_alignment)
        return text
Esempio n. 10
0
class PromoUnit(CMSPlugin):
    icon = Icon(verbose_name=_('Icon'), blank=True, default='')
    image = FilerImageField(
        verbose_name=_('Image'),
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
        related_name='+',
    )
    svg = FilerFileField(
        verbose_name=_('SVG Image'),
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
        related_name='+',
    )
    file_src = FilerFileField(
        verbose_name=_('File'),
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
        related_name='+',
    )
    title = models.CharField(
        max_length=255,
        verbose_name=_('Title'),
        null=True,
        blank=True,
    )
    subtitle = models.CharField(
        max_length=255,
        verbose_name=_('Subtitle'),
        null=True,
        blank=True,
    )
    content = HTMLField(verbose_name=_('Content'), default='', blank=True)
    rollover_content = HTMLField(verbose_name=_('Rollover Content'),
                                 default='',
                                 blank=True)
    background_video = models.CharField(
        max_length=255,
        verbose_name=_('Background Video'),
        null=True,
        blank=True,
    )
    link_url = models.CharField(max_length=255,
                                blank=True,
                                verbose_name=_('Link URL'))
    link_text = models.CharField(max_length=255,
                                 blank=True,
                                 verbose_name=_('Link Text'))
    open_in_new_window = models.BooleanField(
        default=False, verbose_name=_('Open in new window'))
    show_filesize = models.BooleanField(default=True,
                                        verbose_name=_('Show Filesize'))
    alignment = models.CharField(
        verbose_name=_('Alignment'),
        default='',
        blank=True,
        max_length=255,
    )
    layout = models.CharField(blank=True,
                              default='',
                              max_length=60,
                              verbose_name=_('layout'))
    modal_id = models.CharField(
        blank=True,
        default='',
        max_length=60,
        verbose_name=_('Modal Id'),
        help_text=_('Do not include a preceding "#" symbol.'),
    )
    color = RGBColorField(verbose_name=_('Color'), blank=True, null=True)
    full_height = models.BooleanField(default=False,
                                      verbose_name=_('Full Height'))
    attributes = AttributesField()

    def __str__(self):
        return self.title or str(self.pk)
Esempio n. 11
0
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
Esempio n. 12
0
class Bootstrap4Link(AbstractLink):
    """
    Components > "Button" Plugin
    https://getbootstrap.com/docs/4.0/components/buttons/
    """
    url_validators = [
        LocalORIntranetURLValidator(),
    ]

    external_link = models.CharField(
        verbose_name=_('External link'),
        blank=True,
        max_length=2040,
        validators=url_validators,
        help_text=_('Provide a link to an external source.'),
    )
    link_type = models.CharField(
        verbose_name=_('Type'),
        choices=LINK_CHOICES,
        default=LINK_CHOICES[0][0],
        max_length=255,
        help_text=_('Adds either the .btn-* or .text-* classes.'),
    )
    link_color = RGBColorField(verbose_name=_('Color'), blank=True, null=True)
    link_context = models.CharField(
        verbose_name=_('Context'),
        choices=COLOR_STYLE_CHOICES,
        blank=True,
        max_length=255,
    )
    link_size = models.CharField(
        verbose_name=_('Size'),
        choices=LINK_SIZE_CHOICES,
        blank=True,
        max_length=255,
    )
    link_alignment = models.CharField(
        verbose_name=_('Alignment'),
        choices=LINK_ALIGNMENTS,
        blank=True,
        max_length=255,
    )
    link_outline = models.BooleanField(
        verbose_name=_('Outline'),
        default=False,
        help_text=_('Applies the .btn-outline class to the elements.'),
    )
    link_block = models.BooleanField(
        verbose_name=_('Block'),
        default=False,
        help_text=_('Extends the button to the width of its container.'),
    )
    modal_id = models.CharField(
        blank=True,
        default='',
        max_length=60,
        verbose_name=_('Modal Id'),
        help_text=_('Do not include a preceding "#" symbol.'),
    )
    icon_left = Icon(verbose_name=_('Icon left'), )
    icon_right = Icon(verbose_name=_('Icon right'), )
    no_link = models.BooleanField(
        verbose_name=_('No Link'),
        default=False,
    )

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

    def get_link(self):
        if self.no_link:
            return ''
        return super(Bootstrap4Link, self).get_link()

    def clean(self):
        if not self.no_link:
            super(Bootstrap4Link, self).clean()