Skip to content

Content Blocks

cjkcms.blocks.AccordionBlock

Bases: BaseBlock

Allows selecting an accordion snippet

Source code in cjkcms/blocks/content_blocks.py
22
23
24
25
26
27
28
29
30
31
32
33
class AccordionBlock(BaseBlock):
    """
    Allows selecting an accordion snippet
    """

    accordion = SnippetChooserBlock("cjkcms.Accordion")

    class Meta:
        template = "cjkcms/blocks/accordion_block.html"
        icon = "bars"
        label = _("Accordion")
        label_format = _("Accordion")

cjkcms.blocks.CardBlock

Bases: BaseBlock

A component of information with image, text, and buttons.

Source code in cjkcms/blocks/content_blocks.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
class CardBlock(BaseBlock):
    """
    A component of information with image, text, and buttons.
    """

    image = ImageChooserBlock(
        required=False,
        max_length=255,
        label=_("Image"),
    )
    title = blocks.CharBlock(
        required=False,
        max_length=255,
        label=_("Title"),
    )
    subtitle = blocks.CharBlock(
        required=False,
        max_length=255,
        label=_("Subtitle"),
    )
    description = blocks.RichTextBlock(
        features=cms_settings.CJKCMS_RICHTEXT_FEATURES["default"],
        label=_("Body"),
    )
    links = blocks.StreamBlock(
        [("Links", ButtonBlock())],
        blank=True,
        required=False,
        label=_("Links"),
    )

    class Meta:
        template = "cjkcms/blocks/card_foot.html"
        icon = "list-alt"
        label = _("Card")
        label_format = _("{title} (Card)")

    def get_template(self, context=None):
        """Return the default_card_template declared in parent CardGrid,
        otherwise use the default template."""

        if (
            context
            and hasattr(context["self"], "__iter__")
            and "default_card_template" in context["self"]
            and context["self"]["default_card_template"]
        ):
            return context["self"]["default_card_template"]
        else:
            return super().get_template()

get_template

get_template(context=None)

Return the default_card_template declared in parent CardGrid, otherwise use the default template.

Source code in cjkcms/blocks/content_blocks.py
73
74
75
76
77
78
79
80
81
82
83
84
85
def get_template(self, context=None):
    """Return the default_card_template declared in parent CardGrid,
    otherwise use the default template."""

    if (
        context
        and hasattr(context["self"], "__iter__")
        and "default_card_template" in context["self"]
        and context["self"]["default_card_template"]
    ):
        return context["self"]["default_card_template"]
    else:
        return super().get_template()

cjkcms.blocks.CarouselBlock

Bases: BaseBlock

Enables choosing a Carousel snippet.

Source code in cjkcms/blocks/content_blocks.py
88
89
90
91
92
93
94
95
96
97
98
99
class CarouselBlock(BaseBlock):
    """
    Enables choosing a Carousel snippet.
    """

    carousel = SnippetChooserBlock("cjkcms.Carousel")

    class Meta:
        icon = "image"
        label = _("Carousel")
        label_format = _("Carousel")
        template = "cjkcms/blocks/carousel_block.html"

cjkcms.blocks.FilmStripBlock

Bases: BaseBlock

Enables choosing a Film Strip Snippet.

Source code in cjkcms/blocks/content_blocks.py
102
103
104
105
106
107
108
109
110
111
112
class FilmStripBlock(BaseBlock):
    """
    Enables choosing a Film Strip Snippet.
    """

    film_strip = SnippetChooserBlock("cjkcms.FilmStrip")

    class Meta:
        icon = "image"
        label = _("Film Strip")
        template = "cjkcms/blocks/film_strip_block.html"

cjkcms.blocks.ImageGalleryBlock

Bases: BaseBlock

Show a collection of images with interactive previews that expand to full size images in a modal.

Source code in cjkcms/blocks/content_blocks.py
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
class ImageGalleryBlock(BaseBlock):
    """
    Show a collection of images with interactive previews that expand to
    full size images in a modal.
    """

    collection = CollectionChooserBlock(
        required=True,
        label=_("Image Collection"),
    )

    tag = TagChooserBlock(
        required=False,
        label=_("Limit to tag"),
    )

    class Meta:
        template = "cjkcms/blocks/image_gallery_block.html"
        icon = "image"
        label = _("Image Gallery")
        label_format = _("Image Gallery")

cjkcms.blocks.ModalBlock

Bases: ButtonMixin, BaseLayoutBlock

Renders a button that then opens a popup/modal with content.

Source code in cjkcms/blocks/content_blocks.py
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
class ModalBlock(ButtonMixin, BaseLayoutBlock):
    """
    Renders a button that then opens a popup/modal with content.
    """

    header = blocks.CharBlock(
        required=False,
        max_length=255,
        label=_("Modal heading"),
    )
    content = blocks.StreamBlock(
        [],
        label=_("Modal content"),
    )
    footer = blocks.StreamBlock(
        [
            (
                "text",
                blocks.CharBlock(
                    icon="file-text-o", max_length=255, label=_("Simple Text")
                ),
            ),  # noqa
            ("button", ButtonBlock()),
        ],
        required=False,
        label=_("Modal footer"),
    )

    class Meta:
        template = "cjkcms/blocks/modal_block.html"
        icon = "window-maximize"
        label = _("Modal")
        label_format = _("Modal")

cjkcms.blocks.NavDocumentLinkWithSubLinkBlock

Bases: NavSubLinkBlock, NavDocumentLinkBlock

Document link with option for sub-links.

Source code in cjkcms/blocks/content_blocks.py
285
286
287
288
289
290
291
292
class NavDocumentLinkWithSubLinkBlock(NavSubLinkBlock, NavDocumentLinkBlock):
    """
    Document link with option for sub-links.
    """

    class Meta:
        label = _("Document link with sub-links")
        label_format = "{document} (Document link with sub-links)"

cjkcms.blocks.NavExternalLinkWithSubLinkBlock

Bases: NavSubLinkBlock, NavExternalLinkBlock

External link with option for sub-links.

Source code in cjkcms/blocks/content_blocks.py
256
257
258
259
260
261
262
263
class NavExternalLinkWithSubLinkBlock(NavSubLinkBlock, NavExternalLinkBlock):
    """
    External link with option for sub-links.
    """

    class Meta:
        label = _("External link with sub-links")
        label_format = "{link} (External link with sub-links)"

cjkcms.blocks.NavPageLinkWithSubLinkBlock

Bases: NavSubLinkBlock, NavPageLinkBlock

Page link with option for sub-links or showing child pages.

Source code in cjkcms/blocks/content_blocks.py
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
class NavPageLinkWithSubLinkBlock(NavSubLinkBlock, NavPageLinkBlock):
    """
    Page link with option for sub-links or showing child pages.
    """

    show_child_links = blocks.BooleanBlock(
        required=False,
        default=False,
        label=_("Show child pages"),
        help_text=_(
            "Automatically show a link to the Page’s child pages as a dropdown menu."
        ),
    )

    class Meta:
        label = _("Page link with sub-links")
        label_format = "{page} (Page link with sub-links)"

cjkcms.blocks.PriceListBlock

Bases: BaseBlock

A price list, such as a menu for a restaurant.

Source code in cjkcms/blocks/content_blocks.py
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
class PriceListBlock(BaseBlock):
    """
    A price list, such as a menu for a restaurant.
    """

    heading = blocks.CharBlock(
        required=False,
        max_length=255,
        label=_("Heading"),
    )
    items = blocks.StreamBlock(
        [
            ("item", PriceListItemBlock()),
        ],
        label=_("Items"),
    )

    class Meta:
        template = "cjkcms/blocks/pricelist_block.html"
        icon = "usd"
        label = _("Price List")

cjkcms.blocks.ReusableContentBlock

Bases: BaseBlock

Enables choosing a ResusableContent snippet.

Source code in cjkcms/blocks/content_blocks.py
350
351
352
353
354
355
356
357
358
359
360
361
class ReusableContentBlock(BaseBlock):
    """
    Enables choosing a ResusableContent snippet.
    """

    content = SnippetChooserBlock("cjkcms.ReusableContent")

    class Meta:
        icon = "recycle"
        label = _("Reusable Content")
        template = "cjkcms/blocks/reusable_content_block.html"
        label_format = "{content} (Reusable Content)"

cjkcms.blocks.content.events.PublicEventBlock

Bases: BaseBlock

Entry to form a List of public events

Source code in cjkcms/blocks/content/events.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
class PublicEventBlock(BaseBlock):
    """
    Entry to form a List of public events
    """

    title = blocks.CharBlock(
        required=True,
        max_length=255,
        label=_("Title"),
    )

    location = blocks.CharBlock(
        required=False,
        max_length=255,
        label=_("Location"),
        help_text=_("Country and city of the event"),
    )

    start_date = blocks.DateBlock(
        required=True,
        label=_("Start date"),
        help_text=_("Format: YYYY-MM-DD"),
    )

    end_date = blocks.DateBlock(
        required=False,
        label=_("End date"),
        help_text=_("Format: YYYY-MM-DD"),
    )

    description = blocks.RichTextBlock(
        features=["bold", "italic", "ol", "ul", "hr", "link", "document-link", "image"],
        label=_("Description"),
        help_text=_("Optional, short description of the event"),
        required=False,
    )

    url = blocks.URLBlock(
        max_length=255,
        label=_("Event website"),
        required=False,
    )

    hide_after_end_date = blocks.BooleanBlock(
        required=False,
        default=True,
        label=_("Hide after end date"),
        help_text=_("Hide this event after its end date"),
    )

    class Meta:
        template = "cjkcms/blocks/public_event_block.html"
        icon = "view"
        label = "Public Event"
        ordering = ["start_date"]
        label_format = _("{title} (Event)")