Exemplo n.º 1
0
class ProjectBlock(blocks.StructBlock):
    """Block for projects"""

    state = blocks.ChoiceBlock(required=True,
                               help_text="Estado do desenvolvimento",
                               choices=[
                                   ('developing', 'Em desenvolvimento'),
                                   ('done', 'Pronto'),
                                   ('deployed', 'Deployed'),
                                   ('terminated', 'Fora do Ar'),
                               ])
    descrition = blocks.CharBlock(required=True,
                                  help_text="Descrição do projeto")
    links = blocks.ListBlock(
        blocks.StructBlock([
            ('text',
             blocks.CharBlock(required=False, help_text="Nome do Destino")),
            ('url', blocks.URLBlock(required=False,
                                    help_text="URL do Destino")),
        ],
                           icon='link'))

    class Meta:  # noqa
        template = "streams/project_block.html"
        icon = "fa-cubes"
        label = "Projeto"
Exemplo n.º 2
0
class FigureGridBlock2(blocks.StructBlock):
    grid_items = blocks.ListBlock(FigureBlock2())

    class Meta:
        # this is probably the wrong icon but let's run with it for now
        icon = 'grip'
        template = 'wagtailpages/blocks/figure_grid_block2.html'
Exemplo n.º 3
0
class TestimonialsBlock(blocks.StructBlock):
    class TestimonialBlock(blocks.StructBlock):
        author = blocks.CharBlock(min_length=10,
                                  max_length=100,
                                  help_text='Autor')
        author_position = blocks.CharBlock(min_length=10,
                                           max_length=100,
                                           help_text='Posición del Autor',
                                           required=False)
        image = ImageChooserBlock()
        text = blocks.CharBlock(min_length=10,
                                max_length=400,
                                help_text='Texto')

        class Meta:
            icon = 'placeholder'

    title = blocks.CharBlock(min_length=10, max_length=100, help_text='Titulo')
    subtitle = blocks.CharBlock(min_length=10,
                                max_length=400,
                                help_text='Subtítulo')
    testimonials = blocks.ListBlock(TestimonialBlock())

    class Meta:
        icon = 'wagtail'
        template = 'home/blocks/testimonial.html'
class ImageGridBlock(blocks.StructBlock):
    grid_items = blocks.ListBlock(ImageGrid())

    class Meta:
        # this is probably the wrong icon but let's run with it for now
        icon = 'grip'
        template = 'wagtailpages/blocks/image_grid_block.html'
Exemplo n.º 5
0
class TableShelf(Shelf, WithTracking):
    header = blocks.ListBlock(blocks.CharBlock(required=False), default=[], label='Column headings')
    display_header = blocks.BooleanBlock(label='Display the table header?',
                                         required=False)
    body_rows = blocks.ListBlock(blocks.StreamBlock([
        ('simple_text_panel', PlainTextPanel(required=False)),
        ('rich_text_panel', StandardRichTextPanel(required=False)),
        ('icon_card_panel', IconCardPanel(required=False, icon='snippet'))
    ]))
    meta_variant = blocks.ChoiceBlock(choices=TABLE_VARIANTS,
                                      default='standard',
                                      label='Variant',
                                      classname='dct-meta-field')

    class Meta:
        form_classname = 'dct-table-shelf dct-meta-panel'
Exemplo n.º 6
0
class LanguageFamilyBlock(blocks.StructBlock):
    name = blocks.CharBlock()
    languages = blocks.ListBlock(LanguageLinkBlock())

    class Meta:
        icon = 'group'
        template = 'mesolex_site/blocks/language_family/family.html'
Exemplo n.º 7
0
class HomePage(Page):
    """Customized portfolio homepage with editing capabilities."""

    contact_email = StreamField([('contact_email', blocks.EmailBlock())],
                                blank=True)

    portfolio_information = StreamField([
        ('heading', blocks.CharBlock(default='Portfolio Title')),
        ('paragraph', blocks.TextBlock(default='Portfolio Subheading')),
    ])

    external_portfolio_links = StreamField([('links', ExternalPortfolioLink())
                                            ])
    project_images = StreamField(
        [('project_example',
          blocks.ListBlock(ProjectImageBlock,
                           template='blocks/portfolio_image.html'))],
        blank=True,
    )

    content_panels = Page.content_panels + [
        StreamFieldPanel('portfolio_information'),
        StreamFieldPanel('contact_email'),
        StreamFieldPanel('external_portfolio_links'),
        StreamFieldPanel('project_images'),
    ]

    class Meta:
        verbose_name = 'homepage'
Exemplo n.º 8
0
class DocsBlock(blocks.StructBlock):
    title = blocks.CharBlock()
    images = blocks.ListBlock(ImageChooserBlock())
    body = blocks.RichTextBlock(required=False)

    class Meta:
        template = 'docs/blocks/docs_block.html'
Exemplo n.º 9
0
class CardBlock(blocks.StructBlock):

    service_cards_title = blocks.CharBlock(required=True,
                                           help_text="Add Your Title")

    service_cards = blocks.ListBlock(
        blocks.StructBlock([
            ('image', ImageChooserBlock(required=False)),
            ('icon_image', ImageChooserBlock(required=True)),
            ('service_type', blocks.CharBlock(required=True, max_length=50)),
            ('service_description',
             blocks.TextBlock(required=True, max_length=121)),
            ('service_offering_1',
             blocks.CharBlock(required=True, max_length=50)),
            ('service_offering_2',
             blocks.CharBlock(required=True, max_length=50)),
            ('service_offering_3',
             blocks.CharBlock(required=True, max_length=50)),
            ('service_price',
             blocks.DecimalBlock(required=True, decimal_places=2)),
            ('button_to_internal_page',
             blocks.PageChooserBlock(
                 required=False, help_text="Button to a page on your site")),
            ('button_to_url',
             blocks.URLBlock(
                 required=False,
                 help_text='Button to any website using the URL link')),
        ]))

    class Meta:
        template = 'streams/card_block.html'
        icon = 'image'
        label = 'Service Cards'
Exemplo n.º 10
0
class CardsBlock(blocks.StructBlock):
    cards = blocks.ListBlock(Card())

    class Meta:
        template = "blocks/cards_block.html"
        icon = "image"
        label = "Cards"
Exemplo n.º 11
0
class PromoGroupBlock(FlattenValueContext, blocks.StructBlock):
    class Meta:
        template = 'wagtailnhsukfrontend/promo_group.html'

    column = blocks.ChoiceBlock([
        ('one-half', 'One-half'),
        ('one-third', 'One-third'),
    ],
                                default='one-half',
                                required=True)

    size = blocks.ChoiceBlock([
        ('', 'Default'),
        ('small', 'Small'),
    ],
                              required=False)

    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context)
        context['num_columns'] = {
            'one-half': 2,
            'one-third': 3,
        }[value['column']]
        return context

    heading_level = blocks.IntegerBlock(
        min_value=2,
        max_value=4,
        default=3,
        help_text=
        'The heading level affects users with screen readers. Default=3, Min=2, Max=4.'
    )

    promos = blocks.ListBlock(BasePromoBlock)
Exemplo n.º 12
0
class CardBlock(blocks.StructBlock):
    """
    List Block is a block can be `ADD MORE` in one specify block
    For ex in card block when we created in Wagtail:
        - Only one `title` block can be added
        - Multi `card` block can be added 
    """

    title = blocks.CharBlock(required=True, help_text='Single Block title')

    # List Block
    cards = blocks.ListBlock(
        blocks.StructBlock([
            ('image', ImageChooserBlock(required=True)),
            ('title', blocks.CharBlock(required=True, max_length=40)),
            ('text', blocks.TextBlock(required=True, max_length=200)),
            ('button_page', blocks.PageChooserBlock(required=False)),
            ('button_url',
             blocks.URLBlock(
                 required=False,
                 help_text=
                 "If button page above is selected, that will be used."))
        ]))

    class Meta:
        template = "streams/card_block.html"
        icon = "placeholder"
        label = "Card Staff"
Exemplo n.º 13
0
class TurquoiseListBlocks(blocks.StructBlock):
    blocks = blocks.ListBlock(TurquoiseBlock())

    class Meta:
        template = "streams/turquoise_block.html"
        icon = "grip"
        label = "Turquoise blocks"
Exemplo n.º 14
0
class TrombinoscopeBlock(blocks.StructBlock):
    class Meta:
        icon = "user"
        label = "Trombinoscope"
        template = "home/blocks/trombinoscope.html"

    cards = blocks.ListBlock(PersonBlock())
Exemplo n.º 15
0
class Cards4xn(blocks.StructBlock):
    """A 4xn List of misc Cards."""

    cards = blocks.ListBlock(
        blocks.StructBlock([
            ("title",
             blocks.CharBlock(required=False, help_text="Add cards title")),
            ("text",
             blocks.TextBlock(
                 required=True,
                 max_length=350,
                 help_text="Write a short (350 characters) text")),
            ("image",
             ImageChooserBlock(
                 required=False,
                 help_text="Add a profile picture rendered in card")),
            ("link",
             blocks.URLBlock(required=False,
                             help_text="Add a link to the card")),
        ]))

    class Meta:  # noqa
        template = "agrihub/cards_misc_4xn_block.html"
        icon = "doc-full"
        label = "4xn list of cards"
Exemplo n.º 16
0
class BrandsBlock(blocks.StructBlock):
    title = blocks.CharBlock(required=True)
    brands = blocks.ListBlock(ImageChooserBlock())

    class Meta:
        icon = 'pick'
        template = 'core/blocks/brands_block.html'
Exemplo n.º 17
0
class PersonVCards(blocks.StructBlock):
    """A list of cards to render person vcards."""

    cards = blocks.ListBlock(
        blocks.StructBlock([
            ("title",
             blocks.CharBlock(required=False,
                              help_text='Add your title eg. Prof.')),
            ("name", blocks.CharBlock(required=True,
                                      help_text="Add your name")),
            ("surname",
             blocks.CharBlock(required=True, help_text="Add your surname")),
            ("affiliation",
             blocks.CharBlock(required=False,
                              help_text="Add your affilitations name")),
            ("image",
             ImageChooserBlock(
                 required=True,
                 help_text="Add a profile picture rendered in card")),
            ("orcid",
             blocks.CharBlock(required=False, help_text="Add your ORCID")),
            ("website",
             blocks.URLBlock(required=True,
                             help_text="Add a link to you web profile")),
        ]))

    class Meta:  # noqa
        template = "agrihub/vcards_persons_block.html"
        icon = "user"
        label = "List of vcards for Persons"
Exemplo n.º 18
0
class LinkColumnWithHeader(blocks.StructBlock):
    heading = blocks.CharBlock(required=False,
                               help_text="Leave blank if no header required.")
    links = blocks.ListBlock(LinkBlock())

    class Meta:
        template = 'navigation/blocks/footer_column.html',
Exemplo n.º 19
0
class LanguageFamilyMenuBlock(blocks.StructBlock):
    label = blocks.CharBlock(required=False)
    language_families = blocks.ListBlock(LanguageFamilyBlock())

    class Meta:
        icon = 'site'
        template = 'mesolex_site/blocks/language_family/menu.html'
Exemplo n.º 20
0
class CardBlock(blocks.StructBlock):
    """ Crads with image and text and button"""

    title = blocks.CharBlock(required=True, help_text='Add your title')

    cards = blocks.ListBlock(
        blocks.StructBlock([
            ("image", ImageChooserBlock(required=True)),
            ("title",
             blocks.CharBlock(required=True,
                              help_text='Title of your card',
                              max_length=40)),
            ("text",
             blocks.TextBlock(required=True,
                              help_text='Description of your card',
                              max_length=200)),
            ("button_page", blocks.PageChooserBlock(required=False)),
            ("button_url",
             blocks.URLBlock(
                 required=False,
                 help_text=
                 "if the button page above is selected, that will be used first"
             )),
        ]))

    class Meta:
        template = "streams/card_blocks.html"
        icon = "snippet"
        label = "Cards "
Exemplo n.º 21
0
class FullWidthPage(ContentPage):
    formatted_title = models.CharField(
        max_length=255,
        null=True,
        blank=True,
        default='',
        help_text=
        "Use if you need italics in the title. e.g. <em>Italicized words</em>")
    citations = StreamField(
        [('citations', blocks.ListBlock(CitationsBlock()))],
        null=True,
        blank=True)

    template = 'home/full_width_page.html'
    content_panels = ContentPage.content_panels + [
        StreamFieldPanel('citations')
    ]

    promote_panels = Page.promote_panels

    search_fields = ContentPage.search_fields

    @property
    def content_section(self):
        return ''
Exemplo n.º 22
0
class JoinForm(WagtailCaptchaForm):
    paragraph = RichTextField(blank=True)
    describe_list = StreamField([
        ('list', blocks.ListBlock(blocks.CharBlock(label="Пункт списка"), icon="list-ul", template='blocks/list_block'
                                                                                                   '.html')),
    ])

    content_panels = AbstractForm.content_panels + [
        FieldPanel('paragraph', classname="full"),
        StreamFieldPanel('describe_list', classname="full"),
        InlinePanel('form_fields', label="Form fields"),
    ]

    def get_form(self, *args, **kwargs):
        form = super().get_form(*args, **kwargs)

        for name, field in form.fields.items():
            field.label = ''
            # here we want to adjust the widgets on each field
            # if the field is a TextArea - adjust the rows
            #from https://stackoverflow.com/questions/48321770/how-to-modify-attributes-of-the-wagtail-form-input-fields
            if isinstance(field.widget, widgets.Input):
                field.widget.attrs.update({'placeholder': field.help_text})
            if isinstance(field.widget, widgets.Textarea):
                field.widget.attrs.update({'placeholder': field.help_text, 'rows': 4})
            field.help_text= ''
        return form
Exemplo n.º 23
0
class PortfolioIndexPage(Page):
    """Displays portfolio items."""

    intro_title = models.CharField(
        verbose_name=_('Intro title'),
        max_length=250,
        blank=True,
        help_text=_('Optional H1 title for the gallery page.'))
    intro_text = RichTextField(
        blank=True,
        verbose_name=_('Intro text'),
        help_text=_('Optional text to go with the intro text.'))
    order_items_by = models.IntegerField(choices=ITEM_ORDER_TYPES, default=1)
    portfolio_items = StreamField(
        [('portfolio_item',
          blocks.ListBlock(PortfolioItemBlock,
                           template='blocks/portfolio_item.html'))],
        blank=True,
    )

    content_panels = Page.content_panels + [
        FieldPanel('intro_title', classname='full title'),
        FieldPanel('intro_text', classname='full title'),
        FieldPanel('order_items_by'),
        StreamFieldPanel('portfolio_items'),
    ]

    class Meta:
        verbose_name = 'portfolio'
Exemplo n.º 24
0
class GoogleCalendarBlock(blocks.StructBlock):
    calendars = blocks.ListBlock(
        blocks.StructBlock([
            ('source',
             blocks.CharBlock(
                 help_text=_('Calendar ID as given by google calendar'), )),
            ('color', ColorBlock()),
        ]))
    mode = blocks.ChoiceBlock(choices=[
        ('WEEK', _('Week')),
        ('', _('Month')),
        ('AGENDA', _('Agenda')),
    ],
                              required=False)
    height = blocks.IntegerBlock()
    background_color = ColorBlock()
    week_start = blocks.ChoiceBlock(choices=[
        ('2', _('Monday')),
        ('1', _('Sunday')),
        ('7', _('Saturday')),
    ])

    class Meta:
        label = _('Google Calendar')
        icon = 'fa-calendar'
        template = 'google/blocks/calendar.html'
        group = _('Embed')
Exemplo n.º 25
0
class HowSectBlock(blocks.StructBlock):
    step = blocks.ListBlock(HowStepBlock)

    class Meta:  # noqa
        template = "home/how_step_block.html"
        icon = "edit"
        label = "Step"
Exemplo n.º 26
0
class CardBlock(blocks.StructBlock):
    """Cards with image and text en button(s)
	-- Une sorte de liste

	"""

    title = blocks.CharBlock(required=True, help_text="Add your title")
    cards = blocks.ListBlock(
        blocks.StructBlock([
            ("image", ImageChooserBlock(required=True)),
            ("title", blocks.CharBlock(required=True, max_length=77)),
            ("text", blocks.TextBlock(required=True, max_length=400)),
            ("button_page", blocks.PageChooserBlock(required=False)),
            ("button_url",
             blocks.URLBlock(
                 required=False,
                 help_text=
                 "Si le bouton de page précédent et selectioné, cela sera utilisé en premier"
             )),
        ]))

    class Meta:
        template = "core/card_block.html"
        icon = "placeholder"
        label = "Staff Cards"
Exemplo n.º 27
0
class TeamStackBlock(blocks.StructBlock):
    class MemberBlock(blocks.StructBlock):
        member = blocks.CharBlock(min_length=3,
                                  max_length=100,
                                  help_text='Nombre del Miembro')
        member_position = blocks.CharBlock(min_length=3,
                                           max_length=100,
                                           help_text='Posición',
                                           required=False)
        image = ImageChooserBlock()
        text = blocks.CharBlock(min_length=10,
                                max_length=600,
                                help_text='Texto')

        class Meta:
            icon = 'placeholder'

    title = blocks.CharBlock(min_length=10, max_length=100, help_text='Titulo')
    subtitle = blocks.CharBlock(min_length=10,
                                max_length=400,
                                help_text='Subtítulo')

    members = blocks.ListBlock(MemberBlock())

    class Meta:
        icon = 'cogs'
        template = 'home/blocks/team_stack.html'
Exemplo n.º 28
0
class PartnerVCards(blocks.StructBlock):
    """Block to render a partner vcards as listing."""

    cards = blocks.ListBlock(
        blocks.StructBlock([
            ("name", blocks.CharBlock(required=True,
                                      help_text="Add your name")),
            ("description",
             blocks.TextBlock(
                 required=True,
                 max_length=250,
                 help_text="Write a short (250 characters) description")),
            ("logo",
             ImageChooserBlock(
                 required=True,
                 help_text=
                 "Institutions logo rendered in card cropped to 300x200")),
            ("website",
             blocks.URLBlock(required=True,
                             help_text="link to institutions website")),
        ]))

    class Meta:  # noqa
        template = "agrihub/vcards_partner_block.html"
        icon = "group"
        label = "List of vcards for partners"
Exemplo n.º 29
0
class HeroImageCarouselBlock(blocks.StructBlock, BlockTupleMixin):

    slides = blocks.ListBlock(
        blocks.StructBlock([
            ('image', ImageChooserBlock()),
            ('title', blocks.CharBlock(required=False)),
            ('text', blocks.TextBlock(required=False)),
            ('link', LinkBlock()),
        ])
    )
    height = blocks.IntegerBlock(
        default=300,
        label="Hero Image Height (pixels)",
    )
    width = blocks.IntegerBlock(
        default=1000,
        label="Hero Image Width (pixels)",
    )
    cycle_timeout = blocks.IntegerBlock(
        default=10000,
        help_text="The time between automatic image cycles (in milliseonds). Set to 0 to disable automatic cycling."
    )

    class Meta:
        template = 'jetstream/blocks/hero_image_carousel_block.html'
        form_classname = 'image-carousel struct-block'
        label = 'Hero Image Slider'
        icon = 'image'
Exemplo n.º 30
0
class SubmenuBlock(blocks.StructBlock):
    title = blocks.CharBlock()
    overview_page = blocks.PageChooserBlock(required=False)
    featured_links = blocks.ListBlock(LinkBlock(), default=[])
    other_links = blocks.ListBlock(LinkWithIconBlock(), default=[])
    columns = blocks.ListBlock(SubmenuColumnBlock(), default=[])

    def bulk_to_python(self, values):
        """Support bulk page retrieval to reduce database queries."""
        page_ids = set(chain(*map(self.get_referenced_page_ids, values)))
        pages = Page.objects.in_bulk(page_ids)

        for value in values:
            self.replace_referenced_page_ids_with_pages(value, pages)

        return [blocks.StructValue(self, value) for value in values]

    def get_referenced_page_ids(self, value):
        """Collect all page IDs referenced by this block."""
        page_ids = list()

        # The submenu overview page.
        page_ids.append(value.get('overview_page'))

        # Any pages in featured, other, and column links.
        page_ids.extend(link.get('page') for link in self.link_iterator(value))

        # Return the unique set of non-null page IDs.
        return set(page_id for page_id in page_ids if page_id is not None)

    def replace_referenced_page_ids_with_pages(self, value, pages):
        """Replace page ID references with Page instances."""
        # The submenu overview page.
        if 'overview_page' in value:
            value['overview_page'] = pages.get(value['overview_page'])

        # Any pages in featured, other, and column links.
        for link in self.link_iterator(value):
            if 'page' in link:
                link['page'] = pages.get(link['page'])

    def link_iterator(self, value):
        return chain(
            value.get('featured_links') or [],
            value.get('other_links') or [],
            chain(*((column.get('links') or [])
                    for column in (value.get('columns') or []))))