Ejemplo n.º 1
0
class BootstrapMediaObject(StructBlock):
    """
    Custom 'StructBlock' that allows user to make a bootstrap media object.
    """
    media_img = ImageChooserBlock(required=True)
    media_img_alt = TextBlock(required=True)
    media_img_width = IntegerBlock(
        required=False,
        blank=True,
        help_text="Enter an image width as an integer value. Eg(50)")
    media_img_height = IntegerBlock(
        required=False,
        blank=True,
        help_text="Enter an image height as an integer value Eg(50)")
    heading_text = TextBlock(
        required=False,
        blank=True,
        help_text="enter some heading text for media object")
    body_text = RichTextBlock(
        required=True, help_text="Enter some message for the media object")
    custom_class = TextBlock(
        required=False,
        blank=True,
        help_text="control this element by giving unique class names "
        "separated by space and styling the class in css")

    class Meta:
        icon = "fa-align-right"
        template = "blocks/bootstrap/media.html"
Ejemplo n.º 2
0
class ColSpan(StructBlock):
    xs = IntegerBlock(required=False, min_value=1, max_value=12, default=12)
    sm = IntegerBlock(required=False, min_value=1, max_value=12)
    md = IntegerBlock(required=False, min_value=1, max_value=12)
    lg = IntegerBlock(required=False, min_value=1, max_value=12)
    xl = IntegerBlock(required=False, min_value=1, max_value=12)

    class Meta:
        form_template = 'global_utils/forms/column_form.html'
Ejemplo n.º 3
0
class ColOffset(StructBlock):
    xs = IntegerBlock(required=False, min_value=0, max_value=11)
    sm = IntegerBlock(required=False, min_value=0, max_value=11)
    md = IntegerBlock(required=False, min_value=0, max_value=11)
    lg = IntegerBlock(required=False, min_value=0, max_value=11)
    xl = IntegerBlock(required=False, min_value=0, max_value=11)

    class Meta:
        form_template = 'global_utils/forms/column_form.html'
Ejemplo n.º 4
0
class ColOrder(StructBlock):
    xs = IntegerBlock(required=False, min_value=-1, max_value=13)
    sm = IntegerBlock(required=False, min_value=-1, max_value=13)
    md = IntegerBlock(required=False, min_value=-1, max_value=13)
    lg = IntegerBlock(required=False, min_value=-1, max_value=13)
    xl = IntegerBlock(required=False, min_value=-1, max_value=13)

    class Meta:
        form_template = 'global_utils/forms/column_form.html'
Ejemplo n.º 5
0
class BootstrapCard(StructBlock):
    """
    Custom 'StructBlock' that allows the user to make a bootstrap card
    """

    card_width = IntegerBlock(help_text="18 works best for card",
                              required=False,
                              blank=True)
    is_card_img = BooleanBlock(required=False)
    is_card_img_overlay = BooleanBlock(
        required=False,
        default=False,
        help_text="Use image as background for card",
        label="Image Overlay?")
    card_img = ImageChooserBlock(required=False)
    card_img_width = IntegerBlock(required=False,
                                  help_text="provide an image width")
    card_img_height = IntegerBlock(required=False,
                                   help_text="provide an image height")
    card_title = TextBlock(required=False, null=True, blank=True)
    card_text = RichTextBlock(required=False, null=True, blank=True)
    card_bg_color = ChoiceBlock(choices=[
        ('bg-primary', 'DEFAULT'),
        ('bg-secondary', 'GREY'),
        ('bg-success', 'GREEN'),
        ('bg-danger', 'RED'),
        ('bg-warning', 'ORANGE'),
        ('bg-dark', 'DARK'),
        ('bg-light', 'LIGHT'),
    ],
                                blank=True,
                                required=False,
                                help_text="select a background color")
    card_text_color = ChoiceBlock(choices=[
        ('text-primary', 'DEFAULT'),
        ('text-secondary', 'GREY'),
        ('text-success', 'GREEN'),
        ('text-danger', 'RED'),
        ('text-warning', 'ORANGE'),
        ('text-dark', 'DARK'),
        ('text-light', 'LIGHT'),
    ],
                                  blank=True,
                                  required=False,
                                  help_text="select a text color")
    buttons = ListBlock(BootstrapButton(required=False), default=[])
    custom_class = TextBlock(
        required=False,
        blank=True,
        help_text="control this element by giving unique class names "
        "separated by space and styling the class in css")

    class Meta:
        icon = "fa-id-card"
        template = "blocks/bootstrap/card.html"
        help_text = "Create a bootstrap card"
Ejemplo n.º 6
0
class PhotoGallery(StructBlock):
    image_height = IntegerBlock(min_value=0, max_value=2000, default=64)
    image_width = IntegerBlock(min_value=0, max_value=2000, default=260)
    crop_to_fit = BooleanBlock(default=False, required=False)
    photos = ListBlock(PhotoGalleryItem())

    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context)
        return _get_gallery_context(context, value)

    class Meta:
        template = 'common/blocks/photo_gallery_block.html'
Ejemplo n.º 7
0
class CareCardBlock(FlattenValueContext, StructBlock):

    type = ChoiceBlock([
        ('primary', 'Non-urgent'),
        ('urgent', 'Urgent'),
        ('immediate', 'Immediate'),
    ], required=True, default='primary',)
    heading_level = IntegerBlock(required=True, min_value=2, max_value=4, default=3, help_text='The heading level affects users with screen readers. Default=3, Min=2, Max=4.')
    title = CharBlock(required=True)

    class BodyStreamBlock(StreamBlock):
        richtext = RichTextBlock()
        action_link = ActionLinkBlock()
        details = DetailsBlock()
        inset_text = InsetTextBlock()
        image = ImageBlock()
        grey_panel = GreyPanelBlock()
        warning_callout = WarningCalloutBlock()
        summary_list = SummaryListBlock()

    body = BodyStreamBlock(required=True)

    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context)
        context['accessible_title_prefix'] = {
            'primary': 'Non-urgent advice: ',
            'urgent': 'Urgent advice:',
            'immediate': 'Immediate action required:',
        }[value['type']]
        return context

    class Meta:
        icon = 'help'
        template = 'wagtailnhsukfrontend/care_card.html'
Ejemplo n.º 8
0
class WgoBlock(StructBlock):
    sgf = DocumentChooserBlock()
    alignment = WgoAlignmentChoiceBlock()
    width = IntegerBlock(default=700)
    class Meta:
        icon = "placeholder"
        template = "wgo/wgoblock.html"
class CardFeatureBlock(FlattenValueContext, StructBlock):

    feature_heading = CharBlock(required=True)
    heading_level = IntegerBlock(
        min_value=2,
        max_value=6,
        default=3,
        help_text=
        'The heading level affects users with screen readers. Ignore this if there is no label. Default=3, Min=2, Max=6.'
    )
    heading_size = ChoiceBlock(
        [
            ('', 'Default'),
            ('small', 'Small'),
            ('medium', 'Medium'),
            ('large', 'Large'),
        ],
        help_text=
        'The heading size affects the visual size, this follows the front-end library\'s sizing.',
        required=False)

    body = RichTextBlock(required=True)

    class Meta:
        label = 'Feature card'
        icon = 'doc-full'
        template = 'wagtailnhsukfrontend/card.html'
Ejemplo n.º 10
0
class CareCardBlock(FlattenValueContext, StructBlock):

    type = ChoiceBlock(
        [
            ('primary', 'Non-urgent'),
            ('urgent', 'Urgent'),
            ('immediate', 'Immediate'),
        ],
        required=True,
        default='primary',
    )
    heading_level = IntegerBlock(
        required=True,
        min_value=2,
        max_value=4,
        default=3,
        help_text=
        'The heading level affects users with screen readers. Default=3, Min=2, Max=4.'
    )
    title = CharBlock(required=True)
    body = RichTextBlock(required=True)

    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context)
        context['accessible_title_prefix'] = {
            'primary': 'Non-urgent advice: ',
            'urgent': 'Urgent advice:',
            'immediate': 'Immediate action required:',
        }[value['type']]
        return context

    class Meta:
        template = 'wagtailnhsukfrontend/care_card.html'
class PromoGroupBlock(FlattenValueContext, StructBlock):

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

    size = 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 = IntegerBlock(
        min_value=2,
        max_value=6,
        default=3,
        help_text=
        'The heading level affects users with screen readers. Default=3, Min=2, Max=6.'
    )

    promos = ListBlock(BasePromoBlock)

    class Meta:
        template = 'wagtailnhsukfrontend/promo_group.html'
        help_text = 'This component is now deprecated and will be removed from future versions, please use the card group block'
Ejemplo n.º 12
0
class NColumnImageBlock(blocks.StructBlock):
    images = blocks.ListBlock(ImageBlock())
    height = IntegerBlock(min_value=0, required=True, default=380)
    caption = RichTextMiniBlock(required=False)

    class Meta:
        template = 'article/blocks/columnar_image.html'
        label = 'Columnar Images'
Ejemplo n.º 13
0
class FeaturedSectionBlock(StructBlock):
    title = blocks.CharBlock(required=False)
    link_text = blocks.CharBlock(required=False)
    url = blocks.CharBlock()
    position_from_left = IntegerBlock(
        default=9,
        required=True,
        min_value=0,
        max_value=75,
        help_text="Value in percentage (Max: 75)")
    position_from_top = IntegerBlock(default=30,
                                     required=True,
                                     min_value=0,
                                     max_value=40,
                                     help_text="Value in percentage (Max: 40)")
    featured_image = ImageChooserBlock()
    featured_image_label = blocks.CharBlock(required=False)
Ejemplo n.º 14
0
class WarningCalloutBlock(FlattenValueContext, StructBlock):

    title = CharBlock(required=True, default='Important')
    heading_level = IntegerBlock(required=True, min_value=2, max_value=4, default=3, help_text='The heading level affects users with screen readers. Default=3, Min=2, Max=4.')
    body = RichTextBlock(required=True)

    class Meta:
        icon = 'warning'
        template = 'wagtailnhsukfrontend/warning_callout.html'
Ejemplo n.º 15
0
class ImageBlock(StructBlock):
    image = ImageChooserBlock()
    caption = RichTextBlock(blank=True, null=True, required=False)
    alignment = ImageFormatChoiceBlock()
    width = IntegerBlock(default=None,
                         blank=True,
                         null=True,
                         required=False,
                         help_text="optional width in px. Default is auto.")
Ejemplo n.º 16
0
class GreyPanelBlock(FlattenValueContext, StructBlock):

    label = CharBlock(label='heading', required=False)
    heading_level = IntegerBlock(min_value=2, max_value=4, default=3, help_text='The heading level affects users with screen readers. Ignore this if there is no heading. Default=3, Min=2, Max=4.')
    body = RichTextBlock(required=True)

    class Meta:
        icon = 'doc-full-inverse'
        template = 'wagtailnhsukfrontend/grey_panel.html'
Ejemplo n.º 17
0
class DontBlock(FlattenValueContext, StructBlock):

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

    dont = ListBlock(RichTextBlock)

    class Meta:
        icon = 'cross'
        template = 'wagtailnhsukfrontend/dont_list.html'
Ejemplo n.º 18
0
class IframeBlock(blocks.StructBlock):
    source_url = blocks.URLBlock(required=True)
    column_width = blocks.ChoiceBlock(
        [('column-width', 'Column Width (max 650px)'),
         ('width-1200', 'Site Width (max 1200px)'),
         ('full-width', 'Full Width (max 100%)')],
        default='column-width',
        required=False,
        help_text=
        'The maximum width of the iframe. Always use "Column Width" for non-report content types (e.g. blog posts, About pages). Never use "Full-Width" unless specifically instructed to by your designer.'
    )
    width = IntegerBlock(
        required=True,
        help_text=
        'The iframe will look best if the width is at least as large as the column width. Note that the maximum, in 2018 and earlier, used to be 1050.'
    )
    height = IntegerBlock(required=True)
    fallback_image = ImageChooserBlock(
        icon="image",
        required=False,
        help_text="The fallback image will be rendered for the PDF")
    fallback_image_align = blocks.ChoiceBlock(choices=[('center', 'Centered'),
                                                       ('left', 'Left'),
                                                       ('right', 'Right')],
                                              default='center',
                                              required=True)
    fallback_image_width = blocks.ChoiceBlock([('initial', 'Auto'),
                                               ('width-133', 'Medium'),
                                               ('width-166', 'Large'),
                                               ('width-200', 'X-Large')],
                                              default="initial",
                                              required=True)
    fallback_image_use_original = blocks.BooleanBlock(
        required=False,
        help_text=
        "check if you do not want image compressed. Should be checked for all figures."
    )

    class Meta:
        template = 'blocks/iframe.html'
        icon = 'form'
        label = 'Iframe'
        help_text = "Specifiy maximum width and height dimensions for the iframe. On smaller screens, width-to-height ratio will be preserved."
        group = 'Embeds'
Ejemplo n.º 19
0
class BaseStreamBlock(StreamBlock):
    """
    Define the custom blocks that `StreamField` will utilize
    """
    link_block = CaptionedPageLink()
    integer = IntegerBlock(required=True)
    page = PageChooserBlock()
    stream = AnotherStreamBlock()
    rich_text = RichTextBlock()
    list_of_pages = ListBlock(PageChooserBlock())
Ejemplo n.º 20
0
class BootstrapCarousel(StructBlock):
    """
    Custom 'StructBlock' that allows the user to make a bootstrap carousel
    """
    interval = IntegerBlock(default=2000,
                            help_text="""
    The amount of time to delay between automatically cycling an item. If
    false, carousel will not automatically cycle.
    """)
    c_image1 = ImageChooserBlock(required=True)
    c_image1_title = TextBlock(required=False,
                               blank=True,
                               help_text="Give a title for image 1")
    c_image1_body = TextBlock(required=False,
                              blank=True,
                              help_text="Give a body for image 1")
    c_image2 = ImageChooserBlock(required=False)
    c_image2_title = TextBlock(required=False,
                               blank=True,
                               help_text="Give a title for image 2")
    c_image2_body = TextBlock(required=False,
                              blank=True,
                              help_text="Give a body for image 2")
    c_image3 = ImageChooserBlock(required=False)
    c_image3_title = TextBlock(required=False,
                               blank=True,
                               help_text="Give a title for image 3")
    c_image3_body = TextBlock(required=False,
                              blank=True,
                              help_text="Give a body for image 3")
    c_image4 = ImageChooserBlock(required=False)
    c_image4_title = TextBlock(required=False,
                               blank=True,
                               help_text="Give a title for image 4")
    c_image4_body = TextBlock(required=False,
                              blank=True,
                              help_text="Give a body for image 4")
    c_image5 = ImageChooserBlock(required=False)
    c_image5_title = TextBlock(required=False,
                               blank=True,
                               help_text="Give a title for image 5")
    c_image5_body = TextBlock(required=False,
                              blank=True,
                              help_text="Give a body for image 5")
    custom_class = TextBlock(
        required=False,
        blank=True,
        help_text="control this element by giving unique class names "
        "separated by space and styling the class in css")

    class Meta:
        icon = "fa-film"
        template = "blocks/bootstrap/carousel.html"
        help_text = ("Create a bootstrap carousel. Fill the images in order "
                     "to get optimized display.")
Ejemplo n.º 21
0
class PromoBlock(BasePromoBlock):

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

    heading_level = 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.')

    class Meta:
        template = 'wagtailnhsukfrontend/promo.html'
Ejemplo n.º 22
0
class VideoWithQuoteBlock(blocks.StructBlock):
    video = EmbedBlock(help_text="YouTube video URL")
    video_height = IntegerBlock(required=True, default=270)
    video_caption = RichTextMiniBlock(required=False)
    quote = RichTextMiniBlock()
    align_quote = blocks.ChoiceBlock(choices=ALIGNMENT_CHOICES,
                                     default=ALIGNMENT_CHOICES[0][1])

    class Meta:
        icon = 'openquote'
        label = 'Video with quote'
        template = 'article/blocks/video_with_block_quote.html'
Ejemplo n.º 23
0
class TextFieldBlock(OptionalFormFieldBlock):
    default_value = TextBlock(required=False, label=_('Default value'))
    word_limit = IntegerBlock(default=1000, label=_('Word limit'))

    widget = forms.Textarea(attrs={'rows': 5})

    class Meta:
        label = _('Text field (multi line)')
        template = 'stream_forms/render_unsafe_field.html'

    def get_searchable_content(self, value, data):
        return bleach.clean(data or '', tags=[], strip=True)
Ejemplo n.º 24
0
class PostIndexBlock(StructBlock):
    index = PageChooserBlock(page_type=['blog.PostIndex'])
    shown_posts = IntegerBlock(min_value=1)

    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context)
        context['posts'] = Post.objects.live().public() \
                               .descendant_of(value['index']).order_by('-date')[
                           :value['shown_posts']]
        return context

    class Meta:
        template = 'blog/post_index_block.html'
        icon = 'index'
Ejemplo n.º 25
0
class ColumnBlock(StructBlock):
    """
    Define the blocks that all columns will utilize
    """
    background = ImageChooserBlock(
        required=False,
        help_text="This will set the background image of the row.",
        group="Container")
    width = IntegerBlock(
        max_value=12,
        min_value=1,
        default=12,
        blank=True,
        required=False,
        help_text="Select the width of the column, max of 12.",
        group="Container")

    padding = ChoiceBlock(
        choices=[
            ('', 'Select a padding size'),
            ('none', 'None'),
            ('small', 'Small'),
            ('medium', 'Medium'),
            ('large', 'Large'),
        ],
        blank=True,
        required=False,
        help_text=
        "Select how much top and bottom padding you would like on the row.",
        group="Container")

    content = StreamBlock([
        ('heading', HeadingBlock()),
        ('paragraph',
         RichTextBlock(icon="fa-paragraph",
                       template="blocks/paragraph_block.html")),
        ('carousel', Carousel()),
        ('image', ImageBlock()),
        ('banner', BannerBlock()),
        ('quote', BlockQuote()),
        ('heading', HeadingBlock()),
    ],
                          help_text="Add content to column.")

    class Meta:
        icon = "fa-columns"
        template = "blocks/column.html"
        closed = True
Ejemplo n.º 26
0
class EventBlock(StructBlock):
    """
    Events calendar - time block
    """
    age_policy = IntegerBlock(min_value=0,
                              max_value=18,
                              label='Возрастной контроль')
    event_time = DateTimeBlock(label='Дата события')
    mesto_sobytiya = CharBlock(blank=True,
                               required=False,
                               label='Место события')
    image = ImageChooserBlock(required=True, label='Изображение')

    class Meta:
        icon = "title"
        template = "blocks/event_block.html"
class PanelBlock(FlattenValueContext, StructBlock):

    label = CharBlock(required=False)
    heading_level = IntegerBlock(
        min_value=2,
        max_value=6,
        default=3,
        help_text=
        'The heading level affects users with screen readers. Ignore this if there is no label. Default=3, Min=2, Max=6.'
    )
    body = RichTextBlock(required=True)

    class Meta:
        icon = 'doc-full'
        template = 'wagtailnhsukfrontend/panel.html'
        help_text = 'This component is now deprecated and will be removed from future versions, please use the feature card block'
Ejemplo n.º 28
0
class ParagraphWithEmbedBlock(blocks.StructBlock):
    embed = EmbedBlock()
    embed_caption = RichTextMiniBlock(required=False)
    embed_max_width = IntegerBlock(
        required=False,
        help_text="Optional field. Maximum width of the content in pixels to"
        " be requested from the content provider(e.g YouTube). "
        "If the requested width is not supported, provider will be"
        " supplying the content with nearest available width.")
    embed_align = blocks.ChoiceBlock(choices=ALIGNMENT_CHOICES,
                                     default=ALIGNMENT_CHOICES[0][0])
    content = ParagraphBlock()

    class Meta:
        icon = 'media'
        label = 'Embed with text'
        template = 'article/blocks/paragraph_with_embed.html'
Ejemplo n.º 29
0
class ProjectListing(blocks.StructBlock):
    users = SnippetChooserBlock(get_user_model(), required=True)
    page_numer = IntegerBlock(min_value=3, max_value=9)

    #context injector
    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context=parent_context)
        context['project_categories'] = ProjectCategory.objects.all()
        user = value['users'].username
        print(value)
        context['api_url'] = reverse_lazy('project-user-list',
                                          args=[user],
                                          request=None)
        return context

    class Meta:
        template = 'Projects/blocks/project_listing.html'
class PromoBlock(BasePromoBlock):

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

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

    class Meta:
        template = 'wagtailnhsukfrontend/promo.html'
        help_text = 'This component is now deprecated and will be removed from future versions, please use the card block'