예제 #1
0
class HomePage(Page):
    body = fields.StreamField([
        ('paragraph', blocks.RichTextBlock()),
        ('call_to_action', cms_blocks.CallToActionBlock()),
        ('image_call_to_action', cms_blocks.ImageCallToActionBlock()),
        ('columns_text', cms_blocks.ColumnsBlock()),
        ('accordion', cms_blocks.DocsBlock())
    ])

    subtitle = models.CharField(max_length=120, blank=True)

    header_image = models.ForeignKey('wagtailimages.Image',
                                     null=True,
                                     blank=True,
                                     on_delete=models.SET_NULL,
                                     related_name='+')

    content_panels = [
        edit_handlers.FieldPanel('title'),
        edit_handlers.FieldPanel('subtitle'),
        ImageChooserPanel('header_image'),
        edit_handlers.StreamFieldPanel('body')
    ]

    subpage_types = ['cms_home.SimplePage']
예제 #2
0
class StandardPage(wagtail_models.Page):
    """
    A standard content page.
    """

    description = models.TextField(blank=True)
    excerpt = wagtail_fields.RichTextField(blank=True)
    authors = modelcluster_fields.ParentalManyToManyField("users.User")
    date = models.DateTimeField()
    featured_image = models.ForeignKey(
        "wagtailimages.Image",
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name="+",
    )
    body = wagtail_fields.StreamField([
        ("heading", wagtail_blocks.CharBlock()),
        ("paragraph", wagtail_blocks.RichTextBlock()),
        ("section", SectionBlock()),
    ])

    content_panels = wagtail_models.Page.content_panels + [
        wagtail_panels.FieldPanel("description"),
        wagtail_panels.FieldPanel("excerpt"),
        wagtail_panels.FieldPanel("authors"),
        wagtail_panels.FieldPanel("date"),
        wagtail_image_panels.ImageChooserPanel("featured_image"),
        wagtail_panels.StreamFieldPanel("body"),
    ]
예제 #3
0
class ArchivePage(Page):
    body = fields.StreamField([
        ('archive_list', ArchiveListBlock()),
    ])

    description = models.CharField(max_length=200)
    image = models.ForeignKey(
        'images.CustomImage',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    content_panels = Page.content_panels + [
        edit_handlers.FieldPanel('description'),
        image_handlers.ImageChooserPanel('image'),
        edit_handlers.StreamFieldPanel('body'),
    ]

    class Meta:
        verbose_name = _('Archive')

    parent_page_types = [
        'home.HomePage'
    ]
    subpage_types = []
예제 #4
0
class HomePage(Page):
    body = fields.StreamField([
        ('paragraph',
         blocks.RichTextBlock(
             template='meinberlin_cms/blocks/richtext_block.html')),
        ('call_to_action', cms_blocks.CallToActionBlock()),
        ('image_call_to_action', cms_blocks.ImageCallToActionBlock()),
        ('columns_text', cms_blocks.ColumnsBlock()),
        ('projects', cms_blocks.ProjectsWrapperBlock()),
        ('activities', actions_blocks.PlatformActivityBlock()),
        ('accordion', cms_blocks.DocsBlock()),
        ('infographic', cms_blocks.InfographicBlock()),
        ('map_teaser', cms_blocks.MapTeaserBlock())
    ])

    subtitle = models.CharField(max_length=120)

    header_image = models.ForeignKey('meinberlin_cms.CustomImage',
                                     null=True,
                                     blank=True,
                                     on_delete=models.SET_NULL,
                                     related_name='+')
    storefront = models.ForeignKey('meinberlin_cms.Storefront',
                                   on_delete=models.SET_NULL,
                                   null=True,
                                   related_name='+')

    content_panels = Page.content_panels + [
        edit_handlers.FieldPanel('subtitle'),
        ImageChooserPanel('header_image'),
        edit_handlers.StreamFieldPanel('body'),
        SnippetChooserPanel('storefront')
    ]
예제 #5
0
class DocsPage(Page):

    image = models.ForeignKey(
        'images.CustomImage',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    body = fields.StreamField([
        ('documents_list', DocsBlock()),
        ('Text', RichTextBlock())
    ])

    description = models.CharField(max_length=200)

    content_panels = Page.content_panels + [
        ImageChooserPanel('image'),
        edit_handlers.FieldPanel('description'),
        edit_handlers.StreamFieldPanel('body'),
    ]

    class Meta:
        verbose_name = _('Documents')

    parent_page_types = [
        'home.HomePage'
    ]
    subpage_types = []
예제 #6
0
class StreamfieldSimplePage(Page):
    body = fields.StreamField([('paragraph', blocks.RichTextBlock()),
                               ('html', blocks.RawHTMLBlock())],
                              blank=True)

    content_panels = [
        edit_handlers.FieldPanel('title'),
        edit_handlers.StreamFieldPanel('body'),
    ]

    subpage_types = []
예제 #7
0
class ServicesPage(Page):
    intro = models.TextField(null=True, blank=True)
    body = fields.StreamField(
        blocks.StreamBlock(
            [('section', SectionBlock())],
            min_num=4,
            max_num=4,
        ),
        blank=False,
    )

    content_panels = Page.content_panels + [
        edit_handlers.FieldPanel("intro"),
        edit_handlers.StreamFieldPanel("body"),
    ]
예제 #8
0
class Post(wagtail_models.Page):
    """
    A standard post.
    """

    description = models.TextField(blank=True)
    excerpt = wagtail_fields.RichTextField(blank=True)
    authors = modelcluster_fields.ParentalManyToManyField("users.User")
    date = models.DateTimeField()
    featured_image = models.ForeignKey(
        "wagtailimages.Image",
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name="+",
    )
    tags = modelcluster_taggit.ClusterTaggableManager(
        through="home.TaggedPost", blank=True)
    categories = modelcluster_fields.ParentalManyToManyField("home.Category",
                                                             blank=True)
    body = wagtail_fields.StreamField([
        ("heading", wagtail_blocks.CharBlock()),
        ("paragraph", wagtail_blocks.RichTextBlock()),
        ("section", SectionBlock()),
        ("image", wagtail_image_blocks.ImageChooserBlock()),
    ])

    content_panels = wagtail_models.Page.content_panels + [
        wagtail_panels.FieldPanel("description"),
        wagtail_panels.FieldPanel("excerpt"),
        wagtail_panels.FieldPanel("authors"),
        wagtail_panels.FieldPanel("date"),
        wagtail_panels.FieldPanel("tags"),
        wagtail_panels.FieldPanel("categories"),
        wagtail_image_panels.ImageChooserPanel("featured_image"),
        wagtail_panels.StreamFieldPanel("body"),
    ]

    parent_page_types = ["home.PostIndexPage"]
    subpage_types = []

    def set_url_path(self, parent):
        super().set_url_path(parent=parent)
        self.url_path = self.url_path.replace(
            self.slug, "{:%Y/%b/%d/}".format(self.date).lower() + self.slug)
예제 #9
0
class DocsPage(Page):
    body = fields.StreamField([
        ('documents_list', cms_blocks.DocsBlock()),
        ('header',
         blocks.CharBlock(template='meinberlin_cms/blocks/header.html'))
    ])

    description = fields.RichTextField(blank=True)

    content_panels = Page.content_panels + [
        edit_handlers.FieldPanel('description'),
        edit_handlers.StreamFieldPanel('body'),
    ]

    class Meta:
        verbose_name = 'Documents'

    subpage_types = []
예제 #10
0
class SimplePage(Page):
    body = fields.RichTextField(blank=True)
    body_block = fields.StreamField(
        [('text',
          blocks.RichTextBlock(icon='doc-full',
                               template='home/blocks/text.html')),
         ('html', blocks.RawHTMLBlock(template='home/blocks/text.html')),
         ('teasers', TeaserListBlock()), ('columns', ColumnsListBlock()),
         ('projects', CurrentProjectsListBlock()),
         ('updates', UpdatesBlock())],
        blank=True)

    content_panels = [
        edit_handlers.FieldPanel('title'),
        edit_handlers.FieldPanel('body'),
        edit_handlers.StreamFieldPanel('body_block'),
    ]

    parent_page_types = ['home.HomePage']
    subpage_types = []
예제 #11
0
class HomePage(Page):
    body = fields.StreamField([
        ('paragraph', blocks.RichTextBlock()),
        ('background', cms_blocks.BackgroundBlock()),
        ('call_to_action', cms_blocks.CallToActionBlock()),
        ('image_call_to_action', cms_blocks.ImageCallToActionBlock()),
        ('columns_text', cms_blocks.ColumnsBlock()),
        ('accordion', cms_blocks.DocsBlock())
    ])

    subtitle = models.CharField(max_length=120, blank=True)

    header_image = models.ImageField(blank=True)

    content_panels = [
        edit_handlers.FieldPanel('title'),
        edit_handlers.FieldPanel('subtitle'),
        edit_handlers.FieldPanel('header_image'),
        edit_handlers.StreamFieldPanel('body')
    ]

    subpage_types = ['cms_home.SimplePage']
예제 #12
0
class HomePage(RoutablePageMixin, Page):
    template = 'home/home_page.html'

    banner_title = models.CharField(max_length=100, null=True, blank=True)

    banner_subtitle = fields.RichTextField(
        features=["bold", "italic", "image"], null=True, blank=True)
    banner_image = models.ForeignKey("wagtailimages.Image",
                                     on_delete=models.SET_NULL,
                                     null=True,
                                     blank=True,
                                     related_name="image")
    banner_cta = models.ForeignKey("wagtailcore.Page",
                                   on_delete=models.SET_NULL,
                                   null=True,
                                   blank=True,
                                   related_name="link")

    staff_card = fields.StreamField([
        ("cards", blocks.CardBlock()),
    ],
                                    null=True,
                                    blank=True)

    api_fields = [
        banner_title, banner_subtitle, banner_image, banner_cta, staff_card
    ]

    content_panels = Page.content_panels + [
        eh.FieldPanel("banner_title"),
        eh.FieldPanel("banner_subtitle"),
        ImageChooserPanel("banner_image"),
        eh.PageChooserPanel("banner_cta"),
        eh.StreamFieldPanel("staff_card"),
    ]

    class Meta:
        verbose_name = "HOME PAGE"
        verbose_name_plural = "HOME PAGES"
예제 #13
0
class HomePage(Page):
    image = models.ForeignKey(CustomImage,
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL,
                              related_name='+')

    body = fields.StreamField([
        ('text',
         blocks.RichTextBlock(icon='doc-full',
                              template='home/blocks/text.html')),
        ('html', blocks.RawHTMLBlock(template='home/blocks/text.html')),
        ('teasers', TeaserListBlock()), ('columns', ColumnsListBlock()),
        ('projects', CurrentProjectsListBlock()), ('updates', UpdatesBlock())
    ])

    content_panels = Page.content_panels + [
        ImageChooserPanel('image'),
        edit_handlers.StreamFieldPanel('body'),
    ]

    parent_page_types = ['wagtailcore.Page']
예제 #14
0
class MenuItem(models.Model):
    menu_title = models.CharField(max_length=255)

    link_page = models.ForeignKey(
        'wagtailcore.Page',
        related_name='+',
        blank=True,
        null=True,
        help_text=(
            'Creates a link to a single wagtail page. '
            'Leave empty if you add subpages or a link view'
        ),
        on_delete=models.CASCADE
    )

    allowed_views = (
        ('idea-list', 'ideaspace'),
    )

    link_view = models.CharField(
        max_length=100,
        blank=True,
        choices=[
            (name, title) for name, title in allowed_views
        ],
        help_text=(
            'Creates a link to a non wagtail view (e.g ideaspace). '
            'Leave empty if you add subpages or a link page'
        )
    )

    subpages = StreamField(
        [
            ('link', snippets_blocks.LinkBlock())
        ],
        blank=True,
        null=True,
        help_text=(
            'These Links will be displayed in a dropdown menu'
        ),
        verbose_name='Submenu'
    )

    class Meta:
        abstract = True

    @property
    def url(self):
        if self.link_page:
            return self.link_page.url
        else:
            return reverse(self.link_view)

    def __str__(self):
        return self.title

    def clean(self):
        if self.link_page and self.link_view:
            msg = 'Can only either link a view or a page.'
            raise ValidationError({
                'link_view': msg,
                'link_page': msg,
            })
        if not self.link_page and not self.link_view:
            msg = 'Specify either a link to a view or a page.'
            raise ValidationError({
                'link_view': msg,
                'link_page': msg,
            })

    panels = [
        edit_handlers.MultiFieldPanel(
            [
                edit_handlers.FieldPanel('menu_title'),
                edit_handlers.FieldPanel('link_view'),
                edit_handlers.PageChooserPanel('link_page'),
                edit_handlers.StreamFieldPanel('subpages')
            ],
            heading="Menu Item Info",
            classname="collapsible collapsed"
        )]