Пример #1
0
class UnorderedListBlock(StructBlock):
    title = CharBlock(required=False)
    items = ListBlock(
        StructBlock([('title', CharBlock()), ('description', TextBlock()),
                     ('page', PageChooserBlock(required=False))]))
    label = CharBlock(required=False)
    page = PageChooserBlock(required=False)

    class Meta:
        template = 'cms/blocks/unordered_list_block.html'
Пример #2
0
class FeaturedPageBlock(StructBlock):
    title = CharBlock(required=False)
    starred_page = PageChooserBlock(required=False,
                                    help_text='''
        Leave this blank to randomise the starred item
        from the items below.''')
    items = ListBlock(PageChooserBlock(), required=False)

    class Meta:
        template = 'cms/blocks/featured_page_block.html'
Пример #3
0
class MenuItemBlock(StructBlock):
    page = PageChooserBlock(verbose_name=_('page'))
    subitems = SubMenuItemBlock(verbose_name=_('subitems'))

    class Meta:
        verbose_name = _('Menu Item')
        template = "torchbox/includes/menu_item.html"
Пример #4
0
class ArticlePreviewBlock(StructBlock):
    title = blocks.CharBlock(classname="full title")
    excerpt = blocks.RichTextBlock()
    image = ImageChooserBlock()
    link_page = PageChooserBlock()

    class Meta:
        icon = "cogs"
Пример #5
0
class HomePageBlock(StructBlock):
    url = URLBlock(required=False)
    page = PageChooserBlock(required=False)
    title = CharBlock()
    description = RichTextBlock()

    class Meta:
        template = 'cms/blocks/home_page_block.html'
        help_text = '''
Пример #6
0
class TopicGridBlock(StructBlock):
    block_heading = CharBlock(required=True)
    larger_images = BooleanBlock(default=False, required=False)
    items = ListBlock(PageChooserBlock(target_model='topics.TopicIndexPage'))
    read_more_button = ReadMoreButtonBlock(required=False)

    class Meta:
        image = 'pages/images/streamfield_blocks/topic_grid.jpg'
        template = 'pages/streamfield_blocks/topic_grid.html'
Пример #7
0
class TeaserBlock(StructBlock):
    title = blocks.CharBlock(required=False)
    content = RichTextBlock(required=False)
    image = TeaserImageBlock(required=False)

    page = PageChooserBlock(
        required=False,
        help_text='Links to the original page (in "{}") will automatically '
        'point to translated pages (if they exist) in other '
        'languages. Links to a translation will always point to that '
        'translated page, in all languages.'.format(
            TranslatablePageMixin.original_lang_code))
    link = blocks.URLBlock(required=False)
    read_more_text = blocks.CharBlock(required=False)
    boarderless = blocks.BooleanBlock(required=False)

    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context)
        page = value.get('page')
        if page is not None:
            page = TranslatablePageMixin.get_translated_page(page.specific)
        link = value.get('link')
        image_block = value.get('image')
        image = image_block.get('image')
        imagepos = image_block.get('position')
        largeimg = image_block.get('large')
        read_more_text = value.get('read_more_text') or _('Read more')
        lines = not value.get('boarderless')
        context.update({
            'href':
            page.url if page else link,
            'external':
            not bool(page),
            'title':
            value.get('title'),
            'description':
            value.get('content'),
            'readmorelink': {
                'text': read_more_text
            },
            'imgsrc':
            image.get_rendition('max-1200x1200').url if image else '',
            'imgpos':
            imagepos,
            'largeimg':
            largeimg,
            'lines':
            lines,
        })
        return context

    class Meta:
        icon = 'link'
        label = 'Teaser'
        template = 'widgets/teaser.html'
        help_text = 'Choose either a page or an external link'
Пример #8
0
class LinkBlock(StructBlock):
    url = URLBlock(required=False)
    page = PageChooserBlock(required=False)
    label = CharBlock()
    style = LinkStyleChoiceBlock()

    class Meta:
        help_text = '''
        Use either URL or page, if both are filled in URL takes precedence.'''
        template = 'cms/blocks/link_block.html'
Пример #9
0
class ImageListBlock(StructBlock):
    title = CharBlock(required=False)
    items = ListBlock(
        StructBlock([('title', CharBlock()), ('subtitle', CharBlock()),
                     ('description', RichTextBlock()),
                     ('image', ImageChooserBlock()),
                     ('page', PageChooserBlock(required=False))]))

    class Meta:
        template = 'cms/blocks/image_list_block.html'
Пример #10
0
class DSFTeaserBlock(StructBlock):
    page = PageChooserBlock(
        required=False,
        help_text='Links to the original page (in "{}") will automatically '
        'point to translated pages (if they exist) in other '
        'languages. Links to a translation will always point to that '
        'translated page, in all languages.'.format(
            TranslatablePageMixin.original_lang_code))
    module_1 = blocks.BooleanBlock(required=False, default=True)
    module_2 = blocks.BooleanBlock(required=False, default=True)
    module_3 = blocks.BooleanBlock(required=False, default=True)
    module_4 = blocks.BooleanBlock(required=False, default=True)
    module_5 = blocks.BooleanBlock(required=False, default=True)
    module_6 = blocks.BooleanBlock(required=False, default=True)
    module_7 = blocks.BooleanBlock(required=False, default=True)
    phase_b = blocks.BooleanBlock(required=False, default=True)
    phase_c = blocks.BooleanBlock(required=False, default=True)

    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context)
        page = value.get('page')
        if page is not None:
            page = TranslatablePageMixin.get_translated_page(page.specific)
        url = page.url if page else ''

        module_1 = value.get('module_1')
        module_2 = value.get('module_2')
        module_3 = value.get('module_3')
        module_4 = value.get('module_4')
        module_5 = value.get('module_5')
        module_6 = value.get('module_6')
        module_7 = value.get('module_7')

        context.update({
            'module1href':
            '{0}#module-1'.format(url) if module_1 else '',
            'module2href':
            '{0}#module-2'.format(url) if module_2 else '',
            'module3href':
            '{0}#module-3'.format(url) if module_3 else '',
            'module4href':
            '{0}#module-4'.format(url) if module_4 else '',
            'module5href':
            '{0}#module-5'.format(url) if module_5 else '',
            'module6href':
            '{0}#module-6'.format(url) if module_6 else '',
            'module7href':
            '{0}#module-7'.format(url) if module_7 else '',
        })
        return context

    class Meta:
        icon = 'link'
        label = 'DSF Teaser'
        template = 'widgets/dsf-teaser.html'
Пример #11
0
class Header(BaseSetting):
    links = StreamField([
        ('links', StructBlock([
            ('link', PageChooserBlock(required=True)),
            ('text', CharBlock(max_length=255)),
        ], blank=True, null=True))
    ], null=True)

    panels = [
        StreamFieldPanel('links')
    ]
Пример #12
0
class ImageGridBlock(StructBlock):
    title = CharBlock(required=False)
    items = ListBlock(
        StructBlock([('image', ImageChooserBlock()),
                     ('url', URLBlock(required=False)),
                     ('page', PageChooserBlock(required=False))]))

    class Meta:
        help_text = '''
        Use either URL or page, if both are filled in URL takes precedence.'''
        template = 'cms/blocks/image_grid_block.html'
Пример #13
0
class BigTeaserBlock(StructBlock):
    title = CharBlock(required=True)
    subtitle = CharBlock(required=False)
    picture = ImageChooserBlock()
    text = RichTextBlock()
    external_link = URLBlock(
        required=False,
        help_text="Will be ignored if an internal link is provided")
    internal_link = PageChooserBlock(
        required=False,
        help_text='If set, this has precedence over the external link.')

    from_date = DateBlock(required=False)
    to_date = DateBlock(required=False)

    class Meta:
        icon = 'fa fa-list-alt'
        template = 'blocks/big_teaser_block.html'

    def __init__(self, wideimage=False, local_blocks=None, **kwargs):
        super().__init__(local_blocks=local_blocks, **kwargs)
        self.wideimage = wideimage

    def get_context(self, value, parent_context=None):
        context = super(BigTeaserBlock,
                        self).get_context(value, parent_context=parent_context)
        context['super_title'] = value.get('title')

        image = value.get('picture')
        rendition = image.get_rendition('max-800x800')
        context['image'] = {'url': rendition.url, 'name': image.title}
        if value.get('internal_link'):
            context['href'] = value.get('internal_link').url
        else:
            context['href'] = value.get('external_link')
        if context['href']:
            context['text_right_link'] = True
            context['text_right_link_text'] = 'Learn more'

        context.update({
            'title': value.get('subtitle'),
            'description': value.get('text'),
            'divider': True,
            'calendaricon': True,
        })
        if value.get('from_date') and value.get('to_date'):
            context['date'] = '"{} to {}"'.format(
                formats.date_format(value.get('from_date'),
                                    "SHORT_DATE_FORMAT"),
                formats.date_format(value.get('to_date'), "SHORT_DATE_FORMAT"))

        context['wideimage'] = self.wideimage
        return context
Пример #14
0
class OverlayTeaserBlock(StructBlock):
    title = blocks.CharBlock()
    content = RichTextBlock(required=False)
    image = ImageChooserBlock(required=True,
                              help_text='Recommended minimal width: 737px')
    page = PageChooserBlock(
        required=False,
        help_text='Links to the original page (in "{}") will automatically '
        'point to translated pages (if they exist) in other '
        'languages. Links to a translation will always point to that '
        'translated page, in all languages.'.format(
            TranslatablePageMixin.original_lang_code))
    link = blocks.URLBlock(required=False)
    link_text = blocks.CharBlock(required=False)
    top_box = blocks.BooleanBlock(required=False, default=False)

    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context)
        page = value.get('page')
        if page is not None:
            page = TranslatablePageMixin.get_translated_page(page.specific)
        link = value.get('link')
        image = value.get('image')
        link_text = value.get('link_text') or _('Link')
        top = value.get('top_box')
        context.update({
            'title':
            value.get('title'),
            'description':
            value.get('content'),
            'style':
            'box',
            'links': [
                {
                    'href': page.url if page else link,
                    'text': link_text,
                    'external': not bool(page),
                },
            ],
            'imgsrc':
            image.get_rendition('max-1200x1200').url if image else '',
            'flapmd':
            True,
            'topposition':
            top,
        })
        return context

    class Meta:
        icon = 'link'
        label = 'Large Image Teaser'
        template = 'widgets/overlay-teaser-widgetchooser.html'
        help_text = 'Choose either a page or an external link'
Пример #15
0
class ParentMenuBlock(StructBlock):
    parent_link_text = CharBlock()
    parent_internal_link = PageChooserBlock(blank=True,
                                            required=False,
                                            icon='fa-link')
    parent_external_link = CharBlock(blank=True,
                                     required=False,
                                     icon='fa-link')
    child_link = CardsBlock(ChildMenuBlock())

    class Meta:
        template = 'tags/menuitem_parent.html'
Пример #16
0
class OverlayTeaserMapBlock(StructBlock):
    title = blocks.CharBlock()
    content = RichTextBlock(required=False)
    page = PageChooserBlock(
        required=False,
        help_text='Links to the original page (in "{}") will automatically '
        'point to translated pages (if they exist) in other '
        'languages. Links to a translation will always point to that '
        'translated page, in all languages.'.format(
            TranslatablePageMixin.original_lang_code))
    link = blocks.URLBlock(required=False)
    link_text = blocks.CharBlock(required=False)

    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context)
        page = value.get('page')
        if page is not None:
            page = TranslatablePageMixin.get_translated_page(page.specific)
        link = value.get('link')
        link_text = value.get('link_text') or _('Link')
        from wocat.cms.models import CountryPage
        country_pages = CountryPage.objects.live().in_menu()
        countries = [{
            'iso_3166_1_alpha_3': country_page.country.code
        } for country_page in country_pages]

        context.update({
            'title':
            value.get('title'),
            'description':
            value.get('content'),
            'style':
            'box',
            'links': [
                {
                    'href': page.url if page else link,
                    'text': link_text,
                    'external': not bool(page),
                },
            ],
            'countries':
            countries,
            'size':
            'large',
        })
        return context

    class Meta:
        icon = 'link'
        label = 'Map Teaser'
        template = 'widgets/overlay-teaser-widgetchooser.html'
        help_text = 'Choose either a page or an external link'
Пример #17
0
class ChildMenuBlock(StructBlock):
    link_text = CharBlock()
    internal_link = PageChooserBlock(blank=True,
                                     required=False,
                                     icon='fa-link')
    external_link = CharBlock(blank=True, required=False, icon='fa-link')

    # Above: Note we don't use a URLBlock because we need to use arbitrary
    # strings for internal links (e.g. /artists). This is probably a terrible
    # idea and there's likely a better solution, but this works...

    class Meta:
        template = 'tags/menuitem_child.html'
Пример #18
0
class ImageGalleryElementBlock(StructBlock):
    image = ImageChooserBlock(help_text='Recommended minimal width: 737px')
    page = PageChooserBlock(required=False)
    link = blocks.URLBlock(required=False)
    description = blocks.CharBlock(required=False)
    shrink = ChoiceBlock(
        choices=[
            (1, 'S'),
            (2, 'XS'),
            (3, 'XXS'),
        ],
        required=False,
    )
Пример #19
0
class PressStreamBlock(StreamBlock):
    heading = CharBlock(icon="title", classname="title")
    subheading = CharBlock(icon="title", classname="title")
    text = RichTextBlock(icon="pilcrow",
                         features=['bold', 'italic', 'ul', 'ol', 'link'])
    image = ImageChooserBlock(template='press/blocks/image.html')
    image_gallery = ListBlock(CaptionedImageBlock(),
                              icon="image",
                              label="Image Slideshow")
    #image_or_video_gallery = ListBlock(CarouselBlock(), icon="image", label="Image or Video Slideshow")
    video = EmbedBlock()
    project = PageChooserBlock(target_model='design.ProjectPage',
                               template='design/blocks/related_project.html')
    pullquote = BlockQuoteBlock()
    document = DocumentChooserBlock(icon="doc-full-inverse")
Пример #20
0
class ThreeColumnBlock(StructBlock):
    block_heading = CharBlock(required=True)

    first_column_heading = CharBlock(required=True)
    first_column_text = RichTextBlock(required=True)
    first_column_color = ChoiceBlock(choices=COLORS, required=True)
    first_column_icon = ChoiceBlock(choices=ICONS, required=True)
    first_column_page = PageChooserBlock(required=False)

    second_column_heading = CharBlock(required=True)
    second_column_text = RichTextBlock(required=True)
    second_column_color = ChoiceBlock(choices=COLORS, required=True)
    second_column_icon = ChoiceBlock(choices=ICONS, required=True)
    second_column_page = PageChooserBlock(required=False)

    third_column_heading = CharBlock(required=True)
    third_column_text = RichTextBlock(required=True)
    third_column_color = ChoiceBlock(choices=COLORS, required=True)
    third_column_icon = ChoiceBlock(choices=ICONS, required=True)
    third_column_page = PageChooserBlock(required=False)

    class Meta:
        image = 'pages/images/streamfield_blocks/three_columns.jpg'
        template = 'pages/streamfield_blocks/three_columns.html'
Пример #21
0
class ButtonBlock(StructBlock):
    class Meta:
        icon = "placeholder"
        template = "blocks/button_block.html"

    button_text = CharBlock(required=True)
    link_to_internal_page = PageChooserBlock(can_choose_root=True,
                                             required=False)
    link_to_external_page = CharBlock(
        required=False,
        help_text=
        "Manually enter URL  if you want the button link to an external page. This value will override the link above."
    )
    button_color = ChoiceBlock(choices=COLOR_CHOICES,
                               blank=False,
                               required=True)
    button_positon = ChoiceBlock(choices=POSITION_CHOICES,
                                 blank=True,
                                 required=False,
                                 default="left")
Пример #22
0
class SmallTeaserBlock(StructBlock):
    title = CharBlock(required=True)
    picture = ImageChooserBlock()
    text = TextBlock(required=True)
    link = PageChooserBlock(required=True)

    class Meta:
        icon = 'fa fa-list-alt'
        template = 'blocks/small_teaser_block.html'

    def get_context(self, value, parent_context=None):
        context = super(SmallTeaserBlock,
                        self).get_context(value, parent_context=parent_context)
        context['title'] = value.get('title')
        image = value.get('picture')
        rendition = image.get_rendition('fill-640x360-c100')
        context['image'] = {'url': rendition.url, 'name': image.title}
        context['href'] = value.get('link').url
        context['description'] = value.get('text')
        context['arrow_right_link'] = True
        return context
Пример #23
0
class LiveFeedsBlock(StructBlock):
    blog_index_page = PageChooserBlock()
    twitter = CharBlock()

    class Meta:
        template = 'cms/blocks/live_feeds_block.html'
Пример #24
0
class LinkBlock(StructBlock):
    text = CharBlock()
    page = PageChooserBlock()

    class Meta:
        icon = "link"
Пример #25
0
class OverrideablePageChooserBlock(StructBlock):
    page = PageChooserBlock()
    title = TextBlock(help_text="Leave blank to use the page's own title",
                      required=False)
Пример #26
0
class ImageBlock(StructBlock):
    image = ImageChooserBlock(label=u"图片")
    caption = CharBlock(required=False, max_length=255, label=u"图片标题")
    page = PageChooserBlock(can_choose_root=True, required=False, label=u"链接到页面")
Пример #27
0
class TwoColImageBlock(StructBlock):
    image = ImageChooserBlock(label=u"图片")
    desc1 = CharBlock(required=False, max_length=255, label=u"描述1")
    desc2 = CharBlock(required=False, max_length=255, label=u"描述2")
    link_text = CharBlock(required=False, max_length=255, label=u"链接文字")
    page = PageChooserBlock(can_choose_root=True, required=False, label=u"链接到页面")
Пример #28
0
class _MethodBlock(StructBlock):
    page = PageChooserBlock(
        'methods.MethodPage',
        label='Методика',
        help_text="Выберите методику для отображения на главной странице",
    )
Пример #29
0
class LinkItem(StructBlock):
    title = CharBlock(required=True, max_length=255, label=u"标题")
    page = PageChooserBlock(can_choose_root=True, required=False, label=u"链接到页面")
Пример #30
0
class ReadMoreButtonBlock(StructBlock):
    label = CharBlock(default="Find out more", required=False)
    page = PageChooserBlock(required=False)

    class Meta:
        template = 'pages/streamfield_blocks/read-more-button-block.html'