示例#1
0
from home.blocks import (ThumbnailBlock, AsideLinkBlock,
                         ContactInfoBlock, CitationsBlock, ResourceBlock,
                         OptionBlock, CollectionBlock, DocumentFeedBlurb,
                         ExampleParagraph, ExampleForms, ExampleImage,
                         CustomTableBlock, ReportingExampleCards)


stream_factory = functools.partial(
    StreamField,
    [
        ('heading', blocks.CharBlock(classname='full title')),
        ('paragraph', blocks.RichTextBlock()),
        ('html', blocks.RawHTMLBlock()),
        ('image', ImageChooserBlock()),
        ('table', TableBlock()),
        ('custom_table', CustomTableBlock())
    ],
)

def get_content_section(page):
    """
    Find the top-level parent in order to highlight
    the main nav item and set social images.
    Takes a Page object and returns a string of either 'legal', 'help', or ''
    """
    slugs = {
        'help-candidates-and-committees': 'help',
        'legal-resources': 'legal'
    }
    ancestors = page.get_ancestors()
    content_sections = [
示例#2
0
class OigLandingPage(Page):
    """OIG's landing page"""
    intro_message = RichTextField(features=['bold', 'italic', 'link'],
                                  null=True)
    complaint_url = models.URLField(max_length=255,
                                    blank=True,
                                    verbose_name='Complaint URL')
    show_info_message = models.BooleanField(
        help_text='☑︎ display informational message | ☐ hide message')
    info_message = RichTextField(features=['bold', 'italic', 'link'],
                                 null=True,
                                 blank=True)
    stats_content = StreamField(
        [
            ('heading', blocks.CharBlock(classname='full title',
                                         icon='title')),
            ('paragraph', blocks.RichTextBlock()),
            ('html', blocks.RawHTMLBlock(label='HTML')),
            ('image', ImageChooserBlock()),
            ('table', TableBlock(table_options=core_table_options)),
            ('custom_table', CustomTableBlock()),
        ],
        null=True,
        blank=True,
        help_text=
        'If this section is empty, the logo will be shown (for screens larger than phones)'
    )

    recent_reports_url = models.URLField(max_length=255,
                                         blank=True,
                                         verbose_name='All reports URL')
    resources = StreamField(
        [('html', blocks.RawHTMLBlock(label='OIG resources'))],
        null=True,
        blank=True,
    )
    you_might_also_like = StreamField(
        blocks.StreamBlock(
            [('group',
              blocks.ListBlock(
                  LinkBlock(), icon='list-ul', label='Group/column'))],
            max_num=3,
            required=False),
        null=True,
        blank=True,
        help_text='Expects three groups/columns but will accept fewer')

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel('intro_message'),
            FieldPanel(
                'complaint_url',
                help_text='Where should the button in the header link?'),
        ],
                        heading='Header'),
        MultiFieldPanel([
            FieldPanel('show_info_message'),
            FieldPanel('info_message'),
        ],
                        heading='Alert / informational message'),
        FieldPanel('recent_reports_url'),
        StreamFieldPanel('stats_content'),
        StreamFieldPanel('resources', heading='OIG resources'),
        StreamFieldPanel('you_might_also_like'),
    ]

    @property
    def category_filters(self):
        return constants.report_category_groups['oig']