コード例 #1
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"),
    ]
コード例 #2
0
ファイル: models.py プロジェクト: BrianC68/bayer-home-imp
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'
コード例 #3
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)
コード例 #4
0
ファイル: models.py プロジェクト: botvice/wagtail-portfolio
class HomePage(Page):
    parent_page_types = ["wagtailcore.Page"]
    sub_heading = models.CharField(
        max_length=140, 
        blank=True, 
        help_text='Subheading text above the banner title',
    )

    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()),
        ("text", blocks.TextBlock()),
        ("image", blocks.ImageBlock()),
    ], null=True, blank=True)

    # Admin page blocks
    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel("sub_heading"),
            ImageChooserPanel("banner_background_image"),
        ], heading="homepage banner"),
        StreamFieldPanel("body"),
    ]
コード例 #5
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"
コード例 #6
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"),
    ]
コード例 #7
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"),
    ]
コード例 #8
0
ファイル: models.py プロジェクト: ReesMcD/ctrlz
class FlexPage(Page):

    content = StreamField(
        [
            ("title", blocks.TitleBlock()),
            ("text", blocks.TextBlock()),
            ("richtext", blocks.RichTextBlock()),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        StreamFieldPanel("content"),
    ]
コード例 #9
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"
コード例 #10
0
class HomePage(Page):

    lead_text = models.CharField(
        max_length=100,
        null=True,
        blank=True,
        help_text="Den här texten är underrubrik på startsidan"
    )

    button_text = models.CharField(
        max_length=100,
        help_text="Knappens text på startsidan",
        default="Läs mer",
        null=True
    )

    button = models.ForeignKey(
        "wagtailcore.Page",
        help_text = "Vart knappen på startsidan ska länka till",
        blank=True,
        null=True,
        on_delete = models.SET_NULL,
        related_name="+"
    )

    banner_image = models.ForeignKey(
        "wagtailimages.Image",
        help_text = 'Startsidans bild, s.k. "Hero-bilden"',
        blank=True,
        null=True,
        on_delete = models.SET_NULL,
        related_name="+"
    )

    body = StreamField([
        ("title", blocks.TitleBlock()),
        ("gallery", blocks.GalleryBlock()),
        ("richText", wagtail_blocks.RichTextBlock()),
    ], null=True, blank=True)

    content_panels = Page.content_panels + [
        FieldPanel("lead_text"),
        FieldPanel("button_text"),
        PageChooserPanel('button'),
        ImageChooserPanel("banner_image"),
        StreamFieldPanel("body"),
    ]
コード例 #11
0
ファイル: models.py プロジェクト: botvice/wagtail-portfolio
class ProjectsPage(Page):
    parent_page_types = ["projects.ProjectsListingPage"]
    summary = models.TextField(
        blank=False,
        max_length=500,
        help_text='Give a brief summary of the project. Additional details may be included in this page further down if necessary.'
    )

    languages_used = models.TextField(
        blank=False,
        max_length=100,
        help_text='List all the languages used seperating by comma and connecting the last language with an "and"'
    )

    project_image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=False,
        on_delete=models.SET_NULL,
        help_text='Insert an image to be used for the project. It will be cropped to 570px by 370px',
        related_name="+",
    )

    date_started = models.DateField()

    date_widget = widgets.AdminDateInput(
        attrs = {
            'placeholder': 'dd-mm-yyyy'
        }
    )

    body = StreamField([
        ("title", blocks.TitleBlock()),
        ("text", blocks.TextBlock()),
        ("image", blocks.ImageBlock()),
    ], null=True, blank=True)

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel("summary"),
            FieldPanel("languages_used"),
            ImageChooserPanel("project_image"),
            FieldPanel("date_started", widget=date_widget),
        ], heading="standard details"),
        StreamFieldPanel("body"),
    ]
コード例 #12
0
ファイル: models.py プロジェクト: botvice/wagtail-portfolio
class FlexPage(Page):
    class Meta:
        verbose_name = "Page"
        verbose_name_plural = "Pages"

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

    body = StreamField([
        ("title", blocks.TitleBlock()),
        ("text", blocks.TextBlock()),
        ("image", blocks.ImageBlock()),
    ],
                       null=True,
                       blank=True)

    content_panels = Page.content_panels + [
        StreamFieldPanel("body"),
    ]
コード例 #13
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)
コード例 #14
0
class HomePage(Page):
    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()),
    ],
                       null=True,
                       blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('lead_text'),
        PageChooserPanel('button'),
        FieldPanel('button_text'),
        ImageChooserPanel('banner_background_image'),
        StreamFieldPanel('body')
    ]
コード例 #15
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"
コード例 #16
0
class Activity(ClusterableModel):
    class Meta:
        managed = True
        verbose_name = 'Lesson'
        verbose_name_plural = 'Lessons'
        # This was originally called activity. It is now Lessons, because EDU asked for it changed.
        # They like to change their minds a lot, so I have not converted the entire app over to be named lesson, simply reskinned the app.
        # verbose_name = 'Activity'
        # verbose_name_plural = 'Activities'

    createDate = models.DateTimeField(auto_now_add=True)
    modifiedDate = models.DateTimeField(auto_now=True)
    live = models.BooleanField(verbose_name='Publish',
                               default=False,
                               editable=True)
    slug = models.SlugField(
        null=True,
        blank=True,
    )
    title = models.CharField(max_length=50)
    # teachers_guide = models.URLField()
    overview_copy = RichTextField(null=True, blank=True)
    student_copy = RichTextField(null=True, blank=True)
    teachers_desc = StreamField([
        ('title', blocks.TitleBlock()),
        ('copy', wagtail_blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('asset', SnippetChooserBlock('assets.Asset')),
        ('activity', SnippetChooserBlock('activity.Activity')),
        ('document', DocumentChooserBlock()),
        ('embed', EmbedBlock()),
        ('external', blocks.Link()),
        ('google_doc', blocks.GoogleDocEmbed()),
        ('codap', blocks.CODAPEmbed()),
        ('raw_html', wagtail_blocks.RawHTMLBlock()),
        ('header', HeaderBlock()),
        ('list', ListBlock()),
        ('image_text_overlay', ImageTextOverlayBlock()),
        ('cropped_images_with_text', CroppedImagesWithTextBlock()),
        ('list_with_images', ListWithImagesBlock()),
        ('thumbnail_gallery', ThumbnailGalleryBlock()),
        ('chart', ChartBlock()),
        ('map', MapBlock()),
    ],
                                null=True,
                                blank=True)
    students_desc = StreamField([
        ('title', blocks.TitleBlock()),
        ('copy', wagtail_blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('asset', SnippetChooserBlock('assets.Asset')),
        ('activity', SnippetChooserBlock('activity.Activity')),
        ('document', DocumentChooserBlock()),
        ('embed', EmbedBlock()),
        ('external', blocks.Link()),
        ('google_doc', blocks.GoogleDocEmbed()),
        ('codap', blocks.CODAPEmbed()),
        ('raw_html', wagtail_blocks.RawHTMLBlock()),
        ('header', HeaderBlock()),
        ('list', ListBlock()),
        ('image_text_overlay', ImageTextOverlayBlock()),
        ('cropped_images_with_text', CroppedImagesWithTextBlock()),
        ('list_with_images', ListWithImagesBlock()),
        ('thumbnail_gallery', ThumbnailGalleryBlock()),
        ('chart', ChartBlock()),
        ('map', MapBlock()),
    ],
                                null=True,
                                blank=True)

    program = models.ForeignKey('taxonomy.Program',
                                null=True,
                                blank=True,
                                on_delete=models.SET_NULL)
    time_estimate = models.ForeignKey('taxonomy.TimeEstimate',
                                      null=True,
                                      blank=True,
                                      on_delete=models.SET_NULL)
    audience = models.ForeignKey('taxonomy.Audience',
                                 null=True,
                                 blank=True,
                                 on_delete=models.SET_NULL)
    topic = models.ForeignKey('taxonomy.Topic',
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL)
    activity_type = models.ForeignKey('taxonomy.ActivityType',
                                      null=True,
                                      blank=False,
                                      on_delete=models.CASCADE)

    @property
    def tags(self):
        tags = [n.tag for n in self.tag_relationship.all()]
        return tags

    @property
    def learning_spaces(self):
        learning_spaces = [
            n.learning_space for n in self.learningspace_relationship.all()
        ]
        return learning_spaces

    # tag = models.ManyToManyField(
    #     'taxonomy.Tag',
    #     blank=True
    # )

    def __str__(self):
        return self.title

    panels = [
        FieldPanel("live"),
        FieldPanel("slug"),
        FieldPanel("title"),
        # FieldPanel("teachers_guide"),
        FieldPanel("overview_copy"),
        StreamFieldPanel('teachers_desc'),
        StreamFieldPanel('students_desc'),
        SnippetChooserPanel('program'),
        FieldPanel('activity_type'),
        InlinePanel('audience_relationship', label="Audience"),
        InlinePanel('learningspace_relationship', label="Learning Space"),
        InlinePanel('standards_relationship', label="Standards Alignment"),
        InlinePanel('topic_relationship', label="Topics"),
        InlinePanel('tag_relationship', label="Tags"),
    ]

    api_fields = [
        APIField("live"),
        APIField('title'),
        APIField('overview_copy'),
        APIField('teachers_desc'),
        APIField('students_desc'),
        APIField('program', serializer=ProgramSerializer()),
        APIField('activity_type'),
        APIField('audience_relationship'),
        APIField('learningspace_relationship'),
        APIField('standards_relationship'),
        APIField('topic_relationship'),
        APIField('tag_relationship'),
    ]
コード例 #17
0
class ContentPage(Page):
    class Meta:
        managed = True
        verbose_name = 'Content'
        verbose_name_plural = 'Content Pages'

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

    image_alt = models.CharField(max_length=100,
                                 null=True,
                                 blank=True,
                                 help_text='Alt tag for image')

    hero_text = models.CharField(
        max_length=100,
        null=True,
        blank=True,
        help_text='Marketing-speak about GRMI EDU (100 Characters Max)')

    program = models.ForeignKey(
        'taxonomy.Program',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
    )

    featured_title = models.CharField(
        max_length=100,
        null=True,
        blank=True,
        verbose_name='Introduction Title',
        help_text='Title for intro copy (optional)')

    featured_copy = RichTextField(
        features=[
            'bold', 'italic', 'link', 'ol', 'ul', 'document-link', 'image'
        ],
        null=True,
        blank=True,
        verbose_name='Introductory Content Copy',
        help_text='Copy describing the program & the featured curricula')

    body = StreamField([
        ('title', blocks.TitleBlock()),
        ('copy', wagtail_blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('asset', SnippetChooserBlock('assets.Asset')),
        ('activity', SnippetChooserBlock('activity.Activity')),
        ('document', DocumentChooserBlock()),
        ('embed', EmbedBlock()),
        ('header', HeaderBlock()),
        ('list', ListBlock()),
        ('image_text_overlay', ImageTextOverlayBlock()),
        ('cropped_images_with_text', CroppedImagesWithTextBlock()),
        ('list_with_images', ListWithImagesBlock()),
        ('thumbnail_gallery', ThumbnailGalleryBlock()),
        ('chart', ChartBlock()),
        ('map', MapBlock()),
    ],
                       null=True,
                       blank=True)

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            ImageChooserPanel('image'),
            FieldPanel('image_alt'),
            FieldPanel('hero_text', classname="full"),
        ],
                        heading="Hero section"),
        MultiFieldPanel([
            FieldPanel('featured_title'),
            FieldPanel('featured_copy'),
        ],
                        heading="Introduction Section",
                        classname='wagtailuiplus__panel--collapsed'),
        MultiFieldPanel([
            StreamFieldPanel('body'),
            SnippetChooserPanel('program'),
        ],
                        heading="Body")
    ]

    # Export fields over the API
    api_fields = [
        APIField('image'),
        APIField('image_alt'),
        APIField('hero_text'),
        APIField('featured_title'),
        APIField('featured_copy'),
        APIField('program'),
        APIField('body'),
    ]

    def serve(self, request):
        modules = Module.objects.all()
        self.modules = modules
        return super().serve(request)
コード例 #18
0
class BlogPage(Page):
    parent_page_types = ["blogs.BlogListingsPage"]
    subpage_types = []
    template = "blogs/blog_page.html"

    author = models.CharField(
        max_length=150,
        help_text = "Här skriver du in namnet på författaren/författarna.",
        blank=False,
        null=True
    )

    description = models.TextField(
        max_length=300,
        blank=True,
        null=True,
        help_text="En frivillig kort beskrivning om vad ditt inlägg handlar om."
    )

    page_image = models.ForeignKey(
        'wagtailimages.Image',
        related_name="+",
        null=True,
        blank=True,
        help_text="En frivillig bakgrundsbild för sidan. Om ingen bild väljs så får inlägget automatiskt en standardbild.",
        on_delete=models.SET_NULL
    )

    presentation_image = models.ForeignKey(
        'wagtailimages.Image',
        related_name="+",
        null=True,
        blank=True,
        help_text="En frivillig presentationsbild för ditt inlägg. Om ingen bild väljs så får inlägget automatiskt en standardbild.",
        on_delete=models.SET_NULL
    )

    # start_text = models.TextField(
    #     blank=False,
    #     null=True,
    #     help_text="Här kan du skriva ett längre stycke text, som kommer hamna bredvid din presentationsbild. Det här texten är tänkt att vara 'starttexten' på ditt inlägg.",
    # )

    start_text = RichTextField(help_text="Här kan du skriva ett längre stycke text, som kommer hamna bredvid din presentationsbild. Det här texten är tänkt att vara 'starttexten' på ditt inlägg, och bör, för utseendets skull, vara max 6 rader.")

    published = models.DateField(
        blank=True,
        null=False,
        help_text="Här skriver jag inget för jag lägger inte in det i FieldPanel ens",
        default=datetime.date.today
    )

    body = StreamField([
        ("title", blocks.TitleBlock()),
        ("gallery", blocks.GalleryBlock()),
        ("richText", wagtail_blocks.RichTextBlock()),
        ("imageAndText", blocks.ImageAndText())
    ], null=True, blank=True)

    content_panels = Page.content_panels + [
        FieldPanel("author"),
        FieldPanel("description"),
        ImageChooserPanel("page_image"),
        ImageChooserPanel("presentation_image"),
        FieldPanel("start_text"),
        StreamFieldPanel("body"),
    ]
コード例 #19
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")
    ]
コード例 #20
0
ファイル: models.py プロジェクト: burnettenguyen/rocketup
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"),
    ]
コード例 #21
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)
コード例 #22
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"),
            })
コード例 #23
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)
コード例 #24
0
class Module(ClusterableModel):
    template = 'modules/module_page.html'

    createDate = models.DateTimeField(auto_now_add=True)
    modifiedDate = models.DateTimeField(auto_now=True)
    # SETH
    slug = models.SlugField(
        null=True,
        blank=True,
    )
    live = models.BooleanField(verbose_name='Publish',
                               default=False,
                               editable=True)
    hero_image = models.ForeignKey('wagtailimages.Image',
                                   null=True,
                                   blank=True,
                                   on_delete=models.SET_NULL,
                                   related_name='+')
    title = models.CharField(max_length=100)
    subtitle = models.CharField(
        max_length=300,
        null=True,
        blank=True,
    )
    intro_copy = RichTextField(verbose_name="Header Intro",
                               null=True,
                               blank=True)
    overview_copy = RichTextField(verbose_name="Overview Tab Copy",
                                  null=True,
                                  blank=True)
    student_intro = RichTextField(verbose_name="Student Page Intro",
                                  null=True,
                                  blank=True)
    teachers_guide = models.URLField(null=True, blank=True)
    module_download = models.URLField(null=True, blank=True)
    learning_outcomes = RichTextField(
        null=True,
        blank=True,
        verbose_name="Learning Outcomes (displays on Detail tab)")
    teachers_desc = StreamField(
        [
            ('title', blocks.TitleBlock()),
            ('copy', wagtail_blocks.RichTextBlock()),
            ('image', ImageChooserBlock()),
            ('asset', SnippetChooserBlock('assets.Asset')),
            ('activity', SnippetChooserBlock('activity.Activity')),
            ('document', DocumentChooserBlock()),
            ('embed', EmbedBlock()),
            ('youtube', blocks.YouTubeBlock()),
            ('google_doc', blocks.GoogleDocEmbed()),
            ('codap', blocks.CODAPEmbed()),
            ('header', HeaderBlock()),
            ('list', ListBlock()),
            ('image_text_overlay', ImageTextOverlayBlock()),
            ('cropped_images_with_text', CroppedImagesWithTextBlock()),
            ('list_with_images', ListWithImagesBlock()),
            ('thumbnail_gallery', ThumbnailGalleryBlock()),
            ('chart', ChartBlock()),
            ('map', MapBlock()),
        ],
        null=True,
        blank=True,
        verbose_name="Lessons Tab Content",
    )
    students_desc = StreamField(
        [
            ('title', blocks.TitleBlock()),
            ('copy', wagtail_blocks.RichTextBlock()),
            ('image', ImageChooserBlock()),
            ('asset', SnippetChooserBlock('assets.Asset')),
            ('activity', SnippetChooserBlock('activity.Activity')),
            ('document', DocumentChooserBlock()),
            ('embed', EmbedBlock()),
            ('youtube', blocks.YouTubeBlock()),
            ('google_doc', blocks.GoogleDocEmbed()),
            ('codap', blocks.CODAPEmbed()),
            ('header', HeaderBlock()),
            ('list', ListBlock()),
            ('image_text_overlay', ImageTextOverlayBlock()),
            ('cropped_images_with_text', CroppedImagesWithTextBlock()),
            ('list_with_images', ListWithImagesBlock()),
            ('thumbnail_gallery', ThumbnailGalleryBlock()),
            ('chart', ChartBlock()),
            ('map', MapBlock()),
        ],
        null=True,
        blank=True,
        verbose_name="Resources for Students",
    )
    time_estimate = models.ForeignKey('taxonomy.TimeEstimate',
                                      null=True,
                                      blank=True,
                                      on_delete=models.SET_NULL)
    program = models.ForeignKey('taxonomy.Program',
                                null=True,
                                blank=True,
                                on_delete=models.SET_NULL)

    @property
    def standards_alignment(self):
        standards_alignment = [
            n.standard for n in self.standards_relationship.all()
        ]
        return standards_alignment

    @property
    def audience(self):
        audience = [n.audience for n in self.audience_relationship.all()]
        return audience

    @property
    def learning_spaces(self):
        learning_spaces = [
            n.learning_space for n in self.learningspace_relationship.all()
        ]
        return learning_spaces

    @property
    def tags(self):
        tags = [n.tag for n in self.tag_relationship.all()]
        return tags

    @property
    def topics(self):
        topics = [n.topic for n in self.topic_relationship.all()]
        return topics

    panels = [
        MultiFieldPanel(
            [
                FieldPanel('live'),
                FieldPanel('slug'),  # SETH
                FieldPanel('title'),
                FieldPanel('subtitle'),
                FieldPanel('intro_copy'),
                ImageChooserPanel('hero_image'),
            ],
            heading="Header Section"),
        MultiFieldPanel([
            FieldPanel('overview_copy'),
            FieldPanel('student_intro'),
            FieldPanel('learning_outcomes'),
            FieldPanel('teachers_guide'),
            FieldPanel('module_download'),
        ],
                        heading="Intro Content"),
        MultiFieldPanel([
            StreamFieldPanel('teachers_desc'),
            StreamFieldPanel('students_desc'),
        ],
                        heading="Lessons"),
        MultiFieldPanel([
            SnippetChooserPanel('program'),
            SnippetChooserPanel('time_estimate'),
            InlinePanel('audience_relationship', label="Audience"),
            InlinePanel('learningspace_relationship', label="Learning Space"),
            InlinePanel('standards_relationship', label="Standards Alignment"),
            InlinePanel('topic_relationship', label="Topics"),
            InlinePanel('tag_relationship', label="Tags"),
        ],
                        heading="Module Metadata")
    ]

    api_fields = [
        APIField("live"),
        APIField('title'),
        APIField('subtitle'),
        APIField('hero_image'),
        APIField('intro_copy'),
        APIField('student_intro'),
        APIField('learning_outcomes'),
        APIField('teachers_guide'),
        APIField('teachers_desc'),
        APIField('students_desc'),
        APIField('program', serializer=ProgramSerializer()),
        APIField('time_estimate', serializer=TimeEstimateSerializer()),
        APIField('audience_relationship'),
        APIField('learningspace_relationship'),
        APIField('standards_relationship'),
        APIField('topic_relationship'),
        APIField('tag_relationship'),
    ]

    def __str__(self):
        return self.title

    def is_educator(self, **kwargs):
        return self.audience_relationship.filter(audience=6)