示例#1
0
class AgendaItemBlock(blocks.StructBlock):
    start_dt = blocks.DateTimeBlock(label="Start", required=False)
    end_dt = blocks.DateTimeBlock(label="End", required=False)
    description = blocks.CharBlock(max_length=100, required=False)
    location = blocks.CharBlock(max_length=100, required=False)
    speakers = blocks.ListBlock(
        blocks.StructBlock([
            ('name', blocks.CharBlock(required=False)),
            ('url', blocks.URLBlock(required=False)),
        ],
                           icon='user',
                           required=False))

    class Meta:
        icon = 'date'
示例#2
0
class ItemIntroduction(blocks.StructBlock):
    category = blocks.ChoiceBlock(choices=ref.categories, required=False)

    heading = blocks.CharBlock(required=False)
    paragraph = blocks.RichTextBlock(required=False)

    date = blocks.DateTimeBlock(required=False)
    has_social = blocks.BooleanBlock(
        required=False, help_text="Whether to show the share icons or not.")

    class Meta:
        icon = 'form'
        template = '_includes/organisms/item-introduction.html'
        classname = 'block__flush-top'
示例#3
0
class HomePage(CFGOVPage):
    header = StreamField([
        ('info_unit', molecules.InfoUnit()),
        ('half_width_link_blob', molecules.HalfWidthLinkBlob()),
    ],
                         blank=True)

    latest_updates = StreamField([
        ('posts',
         blocks.ListBlock(
             blocks.StructBlock([
                 ('categories',
                  blocks.ChoiceBlock(choices=ref.limited_categories,
                                     required=False)),
                 ('link', atoms.Hyperlink()),
                 ('date', blocks.DateTimeBlock(required=False)),
             ]))),
    ],
                                 blank=True)

    # General content tab
    content_panels = CFGOVPage.content_panels + [
        StreamFieldPanel('header'),
        StreamFieldPanel('latest_updates'),
    ]

    # Tab handler interface
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='General Content'),
        ObjectList(CFGOVPage.sidefoot_panels, heading='Sidebar'),
        ObjectList(CFGOVPage.settings_panels, heading='Configuration'),
    ])

    # Sets page to only be createable at the root
    parent_page_types = ['wagtailcore.Page']

    template = 'index.html'

    objects = PageManager()

    search_fields = CFGOVPage.search_fields + [index.SearchField('header')]

    def get_category_name(self, category_icon_name):
        cats = dict(ref.limited_categories)
        return cats[str(category_icon_name)]

    def get_context(self, request):
        context = super(HomePage, self).get_context(request)
        return context