Ejemplo n.º 1
0
class ColumnsBlock(StructBlock):
    left_column = StreamBlock(BASE_BLOCKS + CONTACT_PERSON_TEASER_BLOCKS)
    right_column = StreamBlock(BASE_BLOCKS + CONTACT_PERSON_TEASER_BLOCKS,
                               required=False)

    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context)
        context['left_column'] = value.get('left_column')
        context['right_column'] = value.get('right_column')
        return context

    class Meta:
        icon = 'fa fa-columns'
        label = 'Columns 1-1'
        template = None
Ejemplo n.º 2
0
class ColumnsBlock(StructBlock):
    left_column = StreamBlock(_COLUMNS_BLOCKS)
    right_column = StreamBlock(
        _COLUMNS_BLOCKS)  # , form_classname='pull-right')

    def get_context(self, value, parent_context=None):
        context = super(ColumnsBlock,
                        self).get_context(value, parent_context=parent_context)
        context['left_column'] = value.get('left_column')
        context['right_column'] = value.get('right_column')
        return context

    class Meta:
        icon = 'fa fa-columns'
        label = 'Columns 1-1'
        template = None
Ejemplo n.º 3
0
 def __init__(self, block_types, **kwargs):
     if isinstance(block_types, Block):
         self.stream_block = block_types
     elif isinstance(block_types, type):
         self.stream_block = block_types()
     else:
         self.stream_block = StreamBlock(block_types)
     super(StreamField, self).__init__(**kwargs)
Ejemplo n.º 4
0
class TwoColumnBlock(StructBlock):
    left_column = StreamBlock([
            ('heading', CharBlock(classname="full title")),
            ('paragraph', RichTextBlock()),
            ('image', ImageChooserBlock()),
        ], icon='arrow-left', label='Left column content')

    right_column = StreamBlock([
            ('heading', CharBlock(classname="full title")),
            ('paragraph', RichTextBlock()),
            ('image', ImageChooserBlock()),
        ], icon='arrow-right', label='Right column content')

    class Meta:
        template = 'home/includes/two_column_block.html'
        icon = 'placeholder'
        label = 'Two Columns'
Ejemplo n.º 5
0
 def __init__(self, block_types, **kwargs):
     super(StreamField, self).__init__(**kwargs)
     if isinstance(block_types, Block):
         self.stream_block = block_types
     elif isinstance(block_types, type):
         self.stream_block = block_types(required=not self.blank)
     else:
         self.stream_block = StreamBlock(block_types, required=not self.blank)
Ejemplo n.º 6
0
class Columns1To1To1To1Block(StructBlock):
    first_column = StreamBlock(_COLUMNS_BLOCKS)
    second_column = StreamBlock(_COLUMNS_BLOCKS)
    third_column = StreamBlock(_COLUMNS_BLOCKS)
    fourth_column = StreamBlock(_COLUMNS_BLOCKS)

    class Meta:
        icon = 'fa fa-columns'
        label = 'Columns 1:1:1:1'
        template = 'widgets/columns-1-1-1-1.html'

    def get_context(self, value, parent_context=None):
        context = super(Columns1To1To1To1Block,
                        self).get_context(value, parent_context=parent_context)
        context['first_column'] = value.get('first_column')
        context['second_column'] = value.get('second_column')
        context['third_column'] = value.get('third_column')
        context['fourth_column'] = value.get('fourth_column')
        return context
Ejemplo n.º 7
0
class Columns1To1To1Block(ColumnsBlock):
    center_column = StreamBlock(_COLUMNS_BLOCKS)

    class Meta:
        label = 'Columns 1:1:1'
        template = 'widgets/columns-1-1-1.html'

    def get_context(self, value):
        context = super().get_context(value)
        context['center_column'] = value.get('center_column')
        return context
Ejemplo n.º 8
0
class Columns1To1To1Block(ColumnsBlock):
    middle_column = StreamBlock(BASE_BLOCKS + CONTACT_PERSON_TEASER_BLOCKS)

    class Meta:
        label = 'Columns 1:1:1'
        template = 'widgets/columns-1-1-1.html'

    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context)
        context['middle_column'] = value.get('middle_column')
        return context
Ejemplo n.º 9
0
class OneColumnBlock(StructBlock):
    back_image = ImageChooserBlock(blank=True)
    background_size = ImageFormatChoiceBlock(choices=SIZE_CHOICES,default="auto")
    one_column = StreamBlock([
           ('heading', CharBlock(classname="full title")),
           ('paragraph', RichTextBlock()),
        ], icon='arrow-left', label='Parallax content')

    class Meta:
        template = 'home/includes/one_column_block.html'
        icon = 'placeholder'
        label = 'One Column'
Ejemplo n.º 10
0
class PromoParagraphBlock(ContentBlock):
    body = StreamBlock([('text', RichTextBlock()),
                        ('call_to_action', ListBlock(CallToActionBlock())),
                        ('spacer',
                         ChoiceBlock(choices=[('15', '15 pixels'),
                                              ('30', '30 pixels'),
                                              ('45', '45 pixels'),
                                              ('60', '60 pixels'),
                                              ('75', '75 pixels'),
                                              ('90', '90 pixels')],
                                     required=False))])

    class Meta:
        template = 'blocks/promo_paragraph.html'
        icon = 'doc-full'
Ejemplo n.º 11
0
class DSFModulesBlock(StructBlock):
    module_1_title = CharBlock()
    module_1 = StreamBlock(DSF_BLOCKS)
    module_2_title = CharBlock()
    module_2 = StreamBlock(DSF_BLOCKS)
    module_3_title = CharBlock()
    module_3 = StreamBlock(DSF_BLOCKS)
    module_4_title = CharBlock()
    module_4 = StreamBlock(DSF_BLOCKS)
    module_5_title = CharBlock()
    module_5 = StreamBlock(DSF_BLOCKS)
    module_6_title = CharBlock()
    module_6 = StreamBlock(DSF_BLOCKS)
    module_7_title = CharBlock()
    module_7 = StreamBlock(DSF_BLOCKS)

    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context)
        modules = {
            1: {
                'content': value.get('module_1'),
                'color': '#403D38',
                'text': value.get('module_1_title')
            },  # _('Operational Strategy and Action plan')
            2: {
                'content': value.get('module_2'),
                'color': '#6E3237',
                'text': value.get('module_2_title')
            },  # _('National and Subnational Level')
            3: {
                'content': value.get('module_3'),
                'color': '#604F3B',
                'text': value.get('module_3_title')
            },  # _('Landscape Level')}
            4: {
                'content': value.get('module_4'),
                'color': '#3B482E',
                'text': value.get('module_4_title')
            },  # _('Sea Level')
            5: {
                'content': value.get('module_5'),
                'color': '#22454E',
                'text': value.get('module_5_title')
            },  # _('SLM Territorial Planning')
            6: {
                'content': value.get('module_6'),
                'color': '#2D446B',
                'text': value.get('module_6_title')
            },  # _('Implementation and scaling out')
            7: {
                'content': value.get('module_7'),
                'color': '#3A3451',
                'text': value.get('module_7_title')
            },  # _('Knowledge management platform for informed decision making')
        }

        sections = []
        sidebar_links = []
        for i in range(1, 8):
            module = modules.get(i)
            content = module.get('content')
            if not content:
                continue  # Do not add this section if there is no content.
            sections.append({
                'content': module.get('content'),
                'id': 'module-{0}'.format(i),
                'module_id': i,
            })
            sidebar_links.append({
                'anchorlink': True,
                'color': 'white',
                'backgroundcolor': module.get('color'),
                'href': '#module-{0}'.format(i),
                'kicker': 'Module {0}'.format(i),
                'text': module.get('text'),
            })

        can_upload_documents = False
        page = context.get('page')
        if page:
            can_upload_documents = page.permissions_for_user(
                context['request'].user).can_edit()

        context.update({
            'sections': sections,
            'sidebar_links': sidebar_links,
            'context': context,
            'can_upload_documents': can_upload_documents,
        })
        return context

    class Meta:
        icon = 'fa fa-th-list'
        label = 'DSF Modules'
        template = 'widgets/tab-infobox.html'