示例#1
0
class FlexPage(Page):

    parent_page_types = ['home.HomePage', 'flex.FlexPage']

    body = StreamField(
        [
            ('title', blocks.TitleBlock()),
            ('cards', blocks.CardsBlock()),
            ('image_and_text', blocks.ImageAndTextBlock()),
            ('cta', blocks.CallToActionBlock()),
            # ('richtext_with_title', blocks.RichTextWithTitleBlock()), # Optional way of doing richtext
            ('richtext',
             wagtail_blocks.RichTextBlock(
                 template='streams/simple_richtext_block.html',
                 features=[
                     'h3', 'bold', 'italic', 'ol', 'ul', 'hr', 'link',
                     'document-link', 'image'
                 ])),
        ],
        null=True,
        blank=True)

    content_panels = Page.content_panels + [StreamFieldPanel('body')]

    class Meta:
        verbose_name = 'Flex (misc) page'
        verbose_name_plural = 'Flex (misc) pages'
示例#2
0
文件: models.py 项目: yetti/rocketman
class FlexPage(Page):
    parent_page_types = ["home.HomePage", "flex.FlexPage"]
    body = StreamField(
        [("title", blocks.TitleBlock()), ("cards", blocks.CardsBlock()),
         ("image_and_text", blocks.ImageAndTextBlock()),
         ("cta", blocks.CallToActionBlock()),
         ("testimonial",
          SnippetChooserBlock(
              target_model='testimonials.Testimonial',
              template="streams/testimonial_block.html",
          )),
         ("pricing_table",
          blocks.PricingTableBlock(table_options=NEW_TABLE_OPTIONS, )),
         ("richtext",
          wagtail_blocks.RichTextBlock(
              template="streams/simple_richtext_block.html",
              features=["bold", "italic", "ol", "ul", "link"])),
         ("large_image",
          ImageChooserBlock(
              help_text='This image will be cropped to 1200px by 775px',
              template="streams/large_image_block.html"))],
        null=True,
        blank=True)

    content_panels = Page.content_panels + [
        StreamFieldPanel("body"),
    ]

    class Meta:
        verbose_name = "Flex (misc) page"
        verbose_name_plural = "Flex (misc) pages"
示例#3
0
class HomePage(Page):
    parent_page_types = ["wagtailcore.Page"]
    subpage_types = ["flex.FlexPage", "services.ServiceListingPage"]
    max_count = 1

    lead_text = models.CharField(max_length=140,
                                 blank=True,
                                 help_text="Banner title here")
    button = models.ForeignKey(
        "wagtailcore.Page",
        blank=True,
        null=True,
        related_name="+",
        help_text="Select an optional page link to",
        on_delete=models.SET_NULL,
    )
    button_text = models.CharField(
        max_length=50,
        default="Read more",
        blank=False,
        help_text="Button text",
    )
    banner_background_image = models.ForeignKey(
        "wagtailimages.Image",
        blank=False,
        null=True,
        related_name="+",
        help_text="The banner background image",
        on_delete=models.SET_NULL,
    )

    body = StreamField(
        [
            ("title", blocks.TitleBlock()),
            ("cards", blocks.CardsBlock()),
            ("ImageAndTextBlock", blocks.ImageAndTextBlock()),
            ("cta", blocks.CallToActionBlock()),
            (
                "testimonial",
                SnippetChooserBlock(
                    target_model="testimonials.Testimonial",
                    template="streams/testimonial_block.html",
                ),
            ),
            (
                "pricing_table",
                blocks.PrincingTableBlock(table_options=NEW_TABLE_OPTIONS),
            ),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        FieldPanel("lead_text"),
        PageChooserPanel("button"),
        FieldPanel("button_text"),
        ImageChooserPanel("banner_background_image"),
        StreamFieldPanel("body"),
    ]
示例#4
0
class HomePage(Page):
    parent_page_types = ["wagtailcore.Page"]
    subpage_types = ["flex.FlexPage", "services.ServiceListingPage", "contact.ContactPage"]
    max_count = 1
    lead_text = models.CharField(
        max_length=140,
        blank=True,
        help_text='Subheading text under the banner title',
    )
    button = models.ForeignKey(
        'wagtailcore.Page',
        blank=True,
        null=True,
        related_name='+',
        help_text='Select an optional page to link to',
        on_delete=models.SET_NULL,
    )
    button_text = models.CharField(
        max_length=50,
        default='Read More',
        blank=False,
        help_text='Button text',
    )
    banner_background_image = models.ForeignKey(
        'wagtailimages.Image',
        blank=False,
        null=True,
        related_name='+',
        help_text='The banner background image',
        on_delete=models.SET_NULL,
    )
    body = StreamField([
        ("title", blocks.TitleBlock()),
        ("cards", blocks.CardsBlock()),
        ("image_and_text", blocks.ImageAndTextBlock()),
        ("cta", blocks.CallToActionBlock()),
        ("testimonial", SnippetChooserBlock(
            target_model='testimonials.Testimonial',
            template="streams/testimonial_block.html",
        )),
        ("pricing_table", blocks.PricingTableBlock(table_options=NEW_TABLE_OPTIONS)),
    ], null=True, blank=True)

    content_panels = Page.content_panels + [
        FieldPanel("lead_text"),
        PageChooserPanel("button"),
        FieldPanel("button_text"),
        ImageChooserPanel("banner_background_image"),
        StreamFieldPanel("body"),
    ]

    def save(self, *args, **kwargs):

        key = make_template_fragment_key(
            "home_page_streams",
            [self.id],
        )
        cache.delete(key)

        return super().save(*args, **kwargs)
示例#5
0
class HomePage(Page):
    parent_page_types = ["wagtailcore.Page"]
    subpage_types = ["flex.FlexPage"]
    max_count = 1
    lead_text = models.CharField(
        max_length=140,
        blank=True,
        help_text="Subheading text under the banner title",
    )

    button = models.ForeignKey(
        "wagtailcore.Page",
        blank=True,
        null=True,
        related_name="+",
        on_delete=models.SET_NULL,
    )

    button_text = models.CharField(
        max_length=50,
        default="Read More",
        blank=False,
        help_text="Button text",
    )

    banner_background_image = models.ForeignKey(
        "wagtailimages.Image",
        blank=False,
        null=True,
        related_name="+",
        help_text="The banner background Image",
        on_delete=models.SET_NULL,
    )

    body = StreamField(
        [
            ("title", blocks.TitleBlock()),
            ("cards", blocks.CardsBlock()),
            ("image_and_text", blocks.ImageAndTextBlock()),
            (
                "richtext",
                wagtail_blocks.RichTextBlock(
                    template="streams/simple_richtext_block.html",
                    features=["bold", "italic", "ol", "ul", "link"],
                ),
            ),
        ],
        null=True,
        blank=True,
    )
    content_panels = Page.content_panels + [
        FieldPanel("lead_text"),
        PageChooserPanel("button"),
        FieldPanel("button_text"),
        ImageChooserPanel("banner_background_image"),
        StreamFieldPanel("body"),
    ]
示例#6
0
class HomePage(Page):

    # fields and attributes
    lead_text = models.CharField(
        max_length=140,
        blank=True,
        help_text="Subheading text under the banner title",
    )

    button = models.ForeignKey(
        'wagtailcore.Page',
        blank=True,
        null=True,
        related_name="+",
        help_text="Select an optional page to link to",
        on_delete=models.SET_NULL,
    )

    button_text = models.CharField(max_length=50,
                                   default="Read More",
                                   blank=False,
                                   help_text='Button text')

    banner_background_image = models.ForeignKey(
        'wagtailimages.Image',
        blank=False,
        null=True,
        related_name='+',
        help_text='A banner background image',
        on_delete=models.SET_NULL,
    )

    body = StreamField(
        [
            ("title", blocks.TitleBlock()),
            ("cards", blocks.CardsBlock()),
        ],
        null=True,
        blank=True,
    )

    # create edit panels for fields
    content_panels = Page.content_panels + [
        FieldPanel("lead_text"),
        PageChooserPanel("button"),
        FieldPanel("button_text"),
        ImageChooserPanel("banner_background_image"),
        StreamFieldPanel("body"),
    ]
示例#7
0
文件: models.py 项目: thedern/edp
class FlexPage(Page):
    # limit where pages may be created
    parent_page_types = ["home.HomePage", "flex.FlexPage"]
    # define custom streamfields, takes list of tuples
    # uses classes defined in streams.blocks
    body = StreamField(
        [
            # names in quotes are arbitrary but should be descriptive
            ("title", blocks.TitleBlock()),
            ("cards", blocks.CardsBlock()),
            ("image_and_text", blocks.ImageAndTextBlock()),
            ('call_to_action', blocks.CallToActionBlock()),
            (
                'richtext_editor',
                wagtail_blocks.RichTextBlock(
                    template='streams/simple_richtext_block.html',
                    # limit available features to the following
                    # features=["bold", "italic", "ol", "ul", "link"]
                )),
            ('large_image',
             ImageChooserBlock(
                 help_text='Add a large image to the page, 1200x775',
                 template="streams/large_image_block.html")),
            ('small_image',
             ImageChooserBlock(
                 help_text='Add a small image to the page, 900x450',
                 template="streams/small_image_block.html")),
            ('pricing_table',
             blocks.PricingTableBlock(table_options=new_table_options)),
        ],
        null=True,
        blank=True)

    # expose the body fields via the admin interface for editing
    content_panels = Page.content_panels + [
        StreamFieldPanel("body"),
        MultiFieldPanel(
            [
                InlinePanel(
                    "carousel_images", max_num=10, min_num=0, label="Image")
            ],
            heading="Carousel Images",
        ),
    ]

    class Meta:
        verbose_name = "Flex (misc) page"
        verbose_name_plural = "Flex (misc) pages"
示例#8
0
class FlexPage(Page):
    parent_page_types = ["home.HomePage","flex.FlexPage"]
    class Meta:
        verbose_name = "Flex (misc) page"
        verbose_name_plural = "Flex (misc) pages"


#Declare the Stream Field
    body = StreamField([
        ('title', blocks.TitleBlock()),
        ('cards', blocks.CardsBlock()),
        ('images', blocks.ImageAndTextBlock()),
        ('cta', blocks.CallToActionBlock()),
        ("testimonials", SnippetChooserBlock(
            target_model = "testimonials.Testimonial",
            template = "streams/testimonial_block.html",
        )),
        ("table", blocks.PricingTableBlock(
            table_options = new_table_options
        )),
        ('rich_text', wagtail_blocks.RichTextBlock(
            template = "streams/simple_richtext_block.html"
        )),
        ('large_image', ImageChooserBlock(
            template = "streams/large_image_block.html",
            help_text = "This image will be cropped 1080px by 900px"
        ))
        #('new_richtext', blocks.NewRichTextBlock())
    ], null = True, blank = True)

    content_panels = Page.content_panels + [
        StreamFieldPanel("body")
    ]

    def save(self,*args,**kwargs):

        key = make_template_fragment_key(
            "flex_page",
            [self.id]
        )

        cache.delete(key)
        return super().save(*args,**kwargs)
示例#9
0
class FlexPage(Page):
    parent_page_types = ["home.HomePage", "flex.FlexPage"]
    body = StreamField(
        [
            ("title", blocks.TitleBlock()),
            ("cards", blocks.CardsBlock()),
            ("image_and_text", blocks.ImageAndTextBlock()),
            ("cta", blocks.CallToActionBlock()),
            ("youtube", blocks.YouTubeEmbedBlock()),
            ("spotify", blocks.SpotifyEmbedBlock()),
            ("podcast", blocks.PodcastEmbedBlock()),
            (
                "richtext",
                wagtail_blocks.RichTextBlock(
                    template="streams/simple_richtext_block.html",
                    features=["bold", "italic", "ol", "ul", "link"],
                ),
            ),
            (
                "large_image",
                ImageChooserBlock(
                    help_text="This image will be cropped to 1200px by 775px",
                    template="streams/large_image_block.html",
                ),
            ),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        StreamFieldPanel("body"),
    ]

    class Meta:
        verbose_name = "Flex (misc) page"
        verbose_name_plural = "Flex (misc) pages"
示例#10
0
class SeiteMitHeroBanner(Page):
    class Meta:
        verbose_name = "Hero Banner"

    template = "home/hero_banner_seite.html"
    hero_titel = models.CharField(
        max_length=140,
        blank=True,
        help_text="Überschrift erster Abschnitt",
    )

    hero_text = models.TextField(
        max_length=500,
        blank=True,
        help_text="Text neben/unter dem Banner. Maximal 500 Zeichen.",
    )

    banner_hintergrund_bild = models.ForeignKey(
        'wagtailimages.Image',
        blank=True,
        null=True,
        related_name='+',
        help_text="Banner Hintergrundbild",
        on_delete=models.SET_NULL,
    )
    bild_link_intern = models.ForeignKey(
        'wagtailcore.Page',
        blank=True,
        null=True,
        related_name='+',
        help_text='Interner Link für das Hintergrundbild hinterlegen',
        on_delete=models.SET_NULL,

    )
    bild_link_extern = models.URLField(
        blank=True,
        help_text='Verlinkung zu einer externen Seite',
    )

    body = StreamField([
        ("titel", blocks.TitelBlock()),
        ("cards", blocks.CardsBlock()),
        ("tabellen_block", blocks.TabellenBlock()),
        ("richtext_with_title", blocks.RichTextMitTitelBlock()),
        # ("richtext", wagtail_blocks.RichTextBlock(
        #     template="streams/simple_richtext_block.html",
        #     # features=["bold", "italic", "ol", "ul", "link"]
        # )),
    ], null=True, blank=True)

    content_panels = Page.content_panels + [
        FieldPanel("hero_titel"),
        FieldPanel("hero_text"),
        ImageChooserPanel("banner_hintergrund_bild"),
        PageChooserPanel("bild_link_intern"),
        FieldPanel("bild_link_extern"),
        StreamFieldPanel("body"),
    ]

    def clean(self):
        super().clean()

        if self.bild_link_intern and self.bild_link_extern:

            raise ValidationError({
                'bild_link_intern': ValidationError("Bitte entweder eine interne Seite auswählen oder nur einen externen Link hinterlegen!"),
                'bild_link_extern': ValidationError("Bitte entweder eine interne Seite auswählen oder nur einen externen Link hinterlegen!"),
            })
示例#11
0
class HomePage(Page):

    template = 'home/home_page.html'

    parent_page_types = ["wagtailcore.Page"]
    subpage_types = [
        "flex.FlexPage", "services.ServiceListingPage", "contact.ContactPage"
    ]
    max_count = 1

    lead_subtitle = models.CharField(
        max_length=20,
        blank=True,
        # Field can be left blank
        help_text="Subheading under banner title",
    )

    lead_text = models.CharField(
        max_length=100,
        blank=True,
        # Field can be left blank
        help_text="Subtext under banner title",
    )

    button = models.ForeignKey(
        'wagtailcore.Page',
        blank=True,
        null=True,
        # Field can be null
        related_name="+",
        help_text='Select an optional page to link to',
        on_delete=models.SET_NULL,
    )

    button_text = models.CharField(
        max_length=50,
        blank=True,
        help_text='Button Text',
    )

    banner_background_image = models.ForeignKey(
        'wagtailimages.Image',
        blank=True,
        null=True,
        related_name="+",
        help_text="The banner background image",
        on_delete=models.SET_NULL,
    )

    body = StreamField(
        [
            ("title", blocks.TitleBlock()),
            ("cards", blocks.CardsBlock()),
            ("image_and_text", blocks.ImageAndTextBlock()),
            ("cta", blocks.CallToActionBlock()),
            ("testimonial",
             SnippetChooserBlock(
                 target_model='testimonials.Testimonials',
                 template="streams/testimonial_block.html",
             )),
            ("pricing_table_block",
             blocks.PricingTableBlock(table_options=NEW_TABLE_OPTIONS)),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        FieldPanel("lead_subtitle"),
        FieldPanel("lead_text"),
        PageChooserPanel("button"),
        FieldPanel("button_text"),
        ImageChooserPanel("banner_background_image"),
        StreamFieldPanel("body"),
    ]
示例#12
0
class HomePage(Page):
    parent_page_types = ["wagtailcore.Page"]
    subpage_types = ["flex.FlexPage", "services.ServiceListingPage","contacts.ContactPage"]
    max_count = 1
    
    lead_text = models.CharField(
        max_length = 140,
        blank = True,
        help_text = "Subsequent text after the banner title idk some other stuff ok?",
    )

    button = models.ForeignKey(
        'wagtailcore.Page',
        blank = True,
        null = True,
        on_delete = models.SET_NULL,
        related_name = '+',
        help_text = "Page Chooser Panel"
    )

    button_text = models.CharField(
        max_length = 50,
        blank = False,
        help_text = "The Button Text",
    )

    banner_background_image = models.ForeignKey(
        'wagtailimages.Image',
        blank = False,
        null = True,
        related_name = '+',
        help_text = 'The banner background image',
        on_delete = models.SET_NULL,
    )

    #Declare the Stream Field
    body = StreamField([
        ('title', blocks.TitleBlock()),
        ('cards', blocks.CardsBlock()),
        ('images', blocks.ImageAndTextBlock()),
        ('cta', blocks.CallToActionBlock()),
        ("testimonials", SnippetChooserBlock(
            target_model = "testimonials.Testimonial",
            template = "streams/testimonial_block.html",
        )),
        ("table", blocks.PricingTableBlock(
            table_options = new_table_options
        ))
    ], null = True, blank = True)

    content_panels = Page.content_panels + [
        FieldPanel("lead_text"),    
        PageChooserPanel("button"),
        FieldPanel("button_text"),
        ImageChooserPanel("banner_background_image"),
        StreamFieldPanel("body"), #Add the stream field to content Panel
    ]

    #*********Remove Caching every time the page gets saved**************
    
    def save(self, *args, **kwargs):

        key = make_template_fragment_key(
            "home_page_streams",
            [self.id], #This value is a list
        )

        cache.delete(key)

        return super().save(*args,**kwargs)
示例#13
0
文件: models.py 项目: yetti/rocketman
class ServicePage(Page):
    parent_page_types = ["services.ServiceListingPage"]
    subpage_types = []
    template = "services/service_page.html"

    description = models.TextField(
        blank=True,
        max_length=500,
    )
    internal_page = models.ForeignKey(
        'wagtailcore.Page',
        blank=True,
        null=True,
        related_name='+',
        help_text='Select an internal Wagtail page',
        on_delete=models.SET_NULL,
    )
    external_page = models.URLField(blank=True)
    button_text = models.CharField(blank=True, max_length=50)
    service_image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=False,
        on_delete=models.SET_NULL,
        help_text=
        'This image will be used on the Service Listing Page and will be cropped to 570px by 370px on this page.',
        related_name='+',
    )

    body = StreamField(
        [("title", blocks.TitleBlock()), ("cards", blocks.CardsBlock()),
         ("image_and_text", blocks.ImageAndTextBlock()),
         ("cta", blocks.CallToActionBlock()),
         ("testimonial",
          SnippetChooserBlock(
              target_model='testimonials.Testimonial',
              template="streams/testimonial_block.html",
          )),
         ("pricing_table",
          blocks.PricingTableBlock(table_options=NEW_TABLE_OPTIONS, )),
         ("richtext",
          wagtail_blocks.RichTextBlock(
              template="streams/simple_richtext_block.html",
              features=["bold", "italic", "ol", "ul", "link"])),
         ("large_image",
          ImageChooserBlock(
              help_text='This image will be cropped to 1200px by 775px',
              template="streams/large_image_block.html"))],
        null=True,
        blank=True)

    content_panels = Page.content_panels + [
        FieldPanel("description"),
        PageChooserPanel("internal_page"),
        FieldPanel("external_page"),
        FieldPanel("button_text"),
        ImageChooserPanel("service_image"),
        StreamFieldPanel("body"),
    ]

    def clean(self):
        super().clean()

        if self.internal_page and self.external_page:
            # Both fields are filled out
            raise ValidationError({
                'internal_page':
                ValidationError(
                    "Please only select a page OR enter an external URL"),
                'external_page':
                ValidationError(
                    "Please only select a page OR enter an external URL"),
            })

        if not self.internal_page and not self.external_page:
            raise ValidationError({
                'internal_page':
                ValidationError(
                    "You must always select a page OR enter an external URL"),
                'external_page':
                ValidationError(
                    "You must always select a page OR enter an external URL"),
            })
示例#14
0
class HomePage(Page):

    parent_page_types = ['wagtailcore.Page']
    subpage_types = [
        'flex.FlexPage', 'services.ServiceListingPage', 'contact.ContactPage',
        'gallery.GalleryListingPage'
    ]
    max_count = 1
    keywords = models.TextField(
        blank=True,
        help_text=
        'Optional comma separated list of keywords to describe the content of this page.'
    )
    lead_text = models.CharField(
        max_length=250,
        blank=True,
        help_text=
        'Subheading text under the banner title, 250 Chars max length.')
    button = models.ForeignKey('wagtailcore.Page',
                               blank=True,
                               null=True,
                               related_name='+',
                               help_text='Select an optional page link.',
                               on_delete=models.SET_NULL)
    button_text = models.CharField(
        max_length=50,
        default='Read More...',
        blank=False,
        help_text='Text shown on the button, 50 Chars max length.')
    body = StreamField([
        ('title', blocks.TitleBlock()),
        ('cards', blocks.CardsBlock()),
        ('image_and_text', blocks.ImageAndTextBlock()),
        ('cta', blocks.CallToActionBlock()),
        ('richtext',
         wagtail_blocks.RichTextBlock(
             template='streams/simple_richtext_block.html',
             features=[
                 'h2', 'h3', 'bold', 'italic', 'ol', 'ul', 'hr', 'link',
                 'document-link', 'image'
             ])),
    ],
                       null=True,
                       blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('keywords'),
        FieldPanel('lead_text'),
        FieldPanel('button_text'),
        PageChooserPanel('button'),
        StreamFieldPanel('body'),
    ]

    def save(self, *args, **kwargs):

        key = make_template_fragment_key(
            'home_page_streams',
            [
                self.id,
            ],
        )
        cache.delete(key)
        return super().save(*args, **kwargs)
示例#15
0
文件: models.py 项目: thedern/edp
class HomePage(Page):
    # limit where home page may be created
    parent_page_types = ["wagtailcore.Page"]
    subpage_types = [
        "flex.FlexPage", "services.ServiceListingPage", "contact.ContactPage"
    ]
    max_count = 1

    lead_text = models.CharField(max_length=140,
                                 blank=True,
                                 help_text='Subheading text under banner')

    button = models.ForeignKey('wagtailcore.Page',
                               blank=True,
                               null=True,
                               related_name='+',
                               help_text='Select an option page to link to',
                               on_delete=models.SET_NULL)

    button_text = models.CharField(
        max_length=50,
        default='Read More',
        blank=False,
        help_text='button text',
    )

    banner_background_image = models.ForeignKey(
        'wagtailimages.Image',
        blank=False,
        null=True,
        related_name='+',
        help_text='The banner background image',
        on_delete=models.SET_NULL)

    # define custom streamfields, takes list of tuples
    # uses classes defined in streams.blocks
    body = StreamField(
        [
            # names in quotes are arbitrary but should be descriptive
            ("title", blocks.TitleBlock()),
            ("cards", blocks.CardsBlock()),
            ("image_and_text", blocks.ImageAndTextBlock()),
            ('call_to_action', blocks.CallToActionBlock()),
            ('pricing_table',
             blocks.PricingTableBlock(table_options=new_table_options)),
            (
                'richtext_editor',
                wagtail_blocks.RichTextBlock(
                    # template='streams/simple_richtext_block.html',
                    # limit available features to the following
                    # features=["bold", "italic", "ol", "ul", "link", "heading", 'h2', 'h3']
                )),
        ],
        null=True,
        blank=True)

    # augment content panels with the fields defined in our model
    # each panel type takes an argument (string) corresponding to the variables above
    content_panels = Page.content_panels + [
        FieldPanel("lead_text"),
        PageChooserPanel('button'),
        FieldPanel("button_text"),
        ImageChooserPanel("banner_background_image"),
        # add panel for streamfield in admin interface
        # can create one or more streamfield blocks on the home page
        StreamFieldPanel("body")
    ]