示例#1
0
class OneToOnePage(Page):
    """
    A Page containing a O2O relation.
    """
    body = RichTextBlock(blank=True)
    page_ptr = models.OneToOneField(Page,
                                    parent_link=True,
                                    related_name='+',
                                    on_delete=models.CASCADE)
示例#2
0
class MinMaxCountStreamModel(models.Model):
    body = StreamField(
        [
            ('text', CharBlock()),
            ('rich_text', RichTextBlock()),
            ('image', ImageChooserBlock()),
        ],
        min_num=2, max_num=5
    )
示例#3
0
class ReviewCustomFormFieldsBlock(CustomFormFieldsBlock):
    char = CharFieldBlock(group=_('Fields'))
    text = TextFieldBlock(group=_('Fields'))
    text_markup = RichTextBlock(group=_('Fields'), label=_('Paragraph'))
    score = ScoreFieldBlock(group=_('Fields'))
    checkbox = CheckboxFieldBlock(group=_('Fields'))
    dropdown = DropdownFieldBlock(group=_('Fields'))

    required_blocks = ReviewMustIncludeFieldBlock.__subclasses__()
    def test_custom_editor_in_rich_text_block(self):
        block = RichTextBlock(editor='custom')

        form_html = block.render_form(block.to_python("<p>hello</p>"), 'body')

        # Check that the custom plugin options are being passed in the hallo initialiser
        self.assertIn(
            'makeHalloRichTextEditable("body", {"halloheadings": {"formatBlocks": ["p", "h2"]}});',
            form_html)
示例#5
0
class PullQuoteBlock(StructBlock):
    quote = RichTextBlock(label='Sitat')
    attribution = CharBlock(label='Tilegnelse', required=False)

    def __str__(self):
        return 'sitat'

    class Meta:
        icon = 'openquote'
示例#6
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 = '''
示例#7
0
class CustomRichBlockFieldPage(Page):
    body = StreamField([
        ("rich_text", RichTextBlock(editor="custom")),
    ])

    content_panels = [
        FieldPanel("title", classname="full title"),
        FieldPanel("body"),
    ]
示例#8
0
class AccordionBlock(StructBlock):
    items = ListBlock(
        AccordionItem())
    footer = RichTextBlock(required=False)

    class Meta:
        icon = 'list-ul'
        template = 'pages/blocks/accordion_block.html'
        label = _('Accordion')
示例#9
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'
示例#10
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'
示例#11
0
 class BodyStreamBlock(StreamBlock):
     richtext = RichTextBlock()
     action_link = ActionLinkBlock()
     details = DetailsBlock()
     inset_text = InsetTextBlock()
     image = ImageBlock()
     grey_panel = GreyPanelBlock()
     warning_callout = WarningCalloutBlock()
     summary_list = SummaryListBlock()
示例#12
0
class BodyBlock(StreamBlock):
    h1 = CharBlock()
    h2 = CharBlock()
    paragraph = RichTextBlock()
    markdown = MarkdownBlock(icon="code")

    image_text = ImageText()
    image_carousel = ListBlock(ImageChooserBlock())
    thumbnail_gallery = ListBlock(ImageChooserBlock())
示例#13
0
class StandardBlock(StreamBlock):
    heading = CharBlock(icon="title")
    paragraph = RichTextBlock(icon="pilcrow")
    image = ImageChooserBlock(icon="image",
                              template='includes/imageblock.html')
    embed = EmbedBlock(icon="code")
    raw_html = RawHTMLBlock(icon="placeholder")
    table = TableBlock(table_options={'renderer': 'html'},
                       template="includes/tableblock.html")
示例#14
0
文件: blocks.py 项目: Hantzis/YEKO
class EscuelaVarillajeAboutSingleImageBlock(StructBlock):
    nombre = CharBlock(required=False)
    imagen = ImageChooserBlock(required=False)
    titulo = CharBlock()
    descripcion = RichTextBlock()

    class Meta:
        icon = 'image'
        template = 'escueladevarillaje/blocks/escuela_varillaje_about_single_image_block.html'
示例#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.")
示例#16
0
class BlogStreamBlock(StreamBlock):
    h2 = CharBlock(icon="title", classname="title")
    h3 = CharBlock(icon="title", classname="title")
    h4 = CharBlock(icon="title", classname="title")
    paragraph = RichTextBlock(icon="pilcrow")
    image = ImageChooserBlock()
    pullquote = PullQuoteBlock()
    document = DocumentChooserBlock(icon="doc-full-inverse")
    code = CodeBlock()
示例#17
0
class CollapsibleBlock(StructBlock):
    visible_text = TextBlock(label="Visible Text")
    hidden_content = RichTextBlock(label="Hidden Content", features=PARAGRAPH_FEATURES)

    class Meta:
        icon = 'placeholder'
        label = 'Collapsible Box'
        admin_text = 'Collapsible Box'
        template = 'blog/blocks/collapsible.html'
示例#18
0
文件: models.py 项目: Kpres/pipeline
class MarqueeBlock(StructBlock):
    body = RichTextBlock(required=True)
    banner_type = ChoiceBlock(
        choices=[("moves", "Rotating")],  # can add stationary later
        default="moves",
        help_text=
        "Determines whether the marquee banner is stationary or rotating. Only rotating works right now.",
        required=True,
    )
示例#19
0
class BaseStreamBlock(StreamBlock):
    """
    Define the custom blocks that `StreamField` will utilize
    """
    link_block = CaptionedPageLink()
    page = PageChooserBlock()
    stream = AnotherStreamBlock()
    rich_text = RichTextBlock()
    list_of_pages = ListBlock(PageChooserBlock())
示例#20
0
def generate_article_body() -> StreamValue:
    return StreamValue(
        StreamBlock([("paragraph", RichTextBlock())]),
        [(
            "paragraph",
            RichText((lambda text, tag: f"<{tag}>{text}</{tag}>")(
                faker.paragraph(nb_sentences=random.randint(30, 100)), "p")),
        ) for _ in range(random.randint(2, 7))],
    )
示例#21
0
class ContactTypeStreamBlock(StreamBlock):
    """Model allowing the CMS to bring together multiple struct block objects."""

    contact_type_editor = StructBlock(
        [('heading', TextBlock()),
         ('description', RichTextBlock(required=False)),
         ('email', TextBlock())],
        icon="title",
        classname="title")
示例#22
0
class CMSStreamBlock(StreamBlock):
    # home = HomePageBlock(icon='grip', label='Homepage Block')

    h2 = CharBlock(icon='title', classname='title')
    h3 = CharBlock(icon='title', classname='title')
    h4 = CharBlock(icon='title', classname='title')
    h5 = CharBlock(icon='title', classname='title')

    intro = RichTextBlock(icon='pilcrow')
    paragraph = RichTextBlock(icon='pilcrow')
    pullquote = PullQuoteBlock(icon='openquote')

    image = ImageBlock(label='Aligned image', icon='image')
    document = DocumentChooserBlock(icon='doc-full-inverse')
    link = LinkBlock(icon='link')
    embed = EmbedBlock(icon='media')

    html = AlignedHTMLBlock(icon='code', label='Raw HTML')
示例#23
0
class FeatureListBlock(StructBlock):
    features = ListBlock(
        StructBlock([("image", ImageChooserBlock(required=True)),
                     ("title",
                      RichTextBlock(features=RICHTEXT_ALL_FEATURES,
                                    required=True))]))

    class Meta:
        template = 'website/blocks/feature_list_block.html'
示例#24
0
class ProducerPage(RoutablePageMixin, PortalPage):
    subtitle = models.CharField(max_length=255,
                                default='Producer Profile',
                                help_text="Page header subtitle")
    bottom_blurb = StreamField([
        ('image', ImageChooserBlock()),
        ('text',
         RichTextBlock(blank=True,
                       features=[
                           'h2', 'h3', 'h4', 'bold', 'italic', 'link', 'ol',
                           'ul', 'hr', 'superscript', 'subscript',
                           'strikethrough', 'blockquote', 'image', 'embed'
                       ])),
        ('google_form',
         LinkBlock(
             label="Google Form Link",
             template="cms/google_form.html",
             help_text=
             "The URL for the Google form. This will be loaded into a popup when clicked."
         )),
        ('HTML',
         RawHTMLBlock(
             label="Custom HTML",
             help_text="For fine-tuning very specific/custom blocks.")),
        ('Embedded_Media', EmbedBlock(label="Embedded Media"))
    ],
                               min_num=0,
                               blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('subtitle', classname="full"),
        FieldPanel('bottom_blurb', classname="full"),
    ]

    @route(r'^$')  # will override the default Page serving mechanism
    @route(r'^(\d+)/$')
    def producer(self, request, id=None):
        """
        View function for the producer page
        """
        if id:
            try:
                provider = Provider.objects.get(pk=id)
            except Exception as e:
                pass
        if not id:
            provider = Provider.objects.all()[0]

        # NOTE: We can use the RoutablePageMixin.render() method to render
        # the page as normal, but with some of the context values overridden
        return self.render(request, context_overrides={
            'provider': provider,
        })

    def get_context(self, request):
        context = super().get_context(request)
        return context
示例#25
0
class BaseStreamBlock(StreamBlock):
    heading_block = HeadingBlock()
    paragraph_block = RichTextBlock(icon="fa-paragraph",
                                    template="blocks/paragraph_block.html")
    image_block = ImageBlock()
    block_quote = BlockQuote()
    embed_block = EmbedBlock(help_text='Insert an embed URL',
                             icon="fa-s15",
                             template="blocks/embed_block.html")
示例#26
0
class CustomRichBlockFieldPage(Page):
    body = StreamField([
        ('rich_text', RichTextBlock(editor='custom')),
    ])

    content_panels = [
        FieldPanel('title', classname="full title"),
        StreamFieldPanel('body'),
    ]
示例#27
0
文件: blocks.py 项目: HyphaApp/hypha
class DeterminationCustomFormFieldsBlock(CustomFormFieldsBlock):
    char = CharFieldBlock(group=_('Fields'))
    text = TextFieldBlock(group=_('Fields'))
    text_markup = RichTextBlock(group=_('Fields'),
                                label=_('Section text/header'))
    checkbox = CheckboxFieldBlock(group=_('Fields'))
    dropdown = DropdownFieldBlock(group=_('Fields'))
    send_notice = SendNoticeBlock(group=_('Fields'))
    required_blocks = DeterminationMustIncludeFieldBlock.__subclasses__()
示例#28
0
class BaseStreamBlock(StreamBlock):
    subheading = CharBlock(
        icon="title",
        classname="title",
        template="categories/blocks/subheading.html"
    )
    paragraph = RichTextBlock(
        features=settings.RICHTEXT_ADVANCED,
        template="categories/blocks/paragraph.html",
        icon="pilcrow",
    )
    linked_image = LinkedImageBlock()
    card = CardBlock()
    image_grid = ProductGridBlock(ProductGridItemBlock(), label="Image grid")
    pullquote = PullQuoteBlock()
    snippet = RichTextBlock(label="Callout", template="categories/blocks/snippet.html")
    html = EmbedHTML(label="Embed code")
    row = RowBlock(max_num=3)
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"
示例#30
0
class InlineStreamPageSection(Orderable):
    page = ParentalKey('tests.InlineStreamPage', related_name='sections', on_delete=models.CASCADE)
    body = StreamField([
        ('text', CharBlock()),
        ('rich_text', RichTextBlock()),
        ('image', ImageChooserBlock()),
    ])
    panels = [
        StreamFieldPanel('body')
    ]