Ejemplo n.º 1
0
class AboutMePage(Page):
    """
    A generic content page. On this demo site we use it for an about page but
    it could be used for any type of page content that only needs a title,
    image, introduction and body field
    """

    intro = RichTextField(blank=True, help_text='Text to describe the page')
    image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
        help_text='Landscape mode only; horizontal width between 1000px and 3000px.'
    )
    body = RichTextField(blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('intro', classname="full"),
        FieldPanel('body'),
        ImageChooserPanel('image'),
    ]
Ejemplo n.º 2
0
class New(models.Model):
    title = models.CharField(max_length=255)
    author = models.ForeignKey(User)
    description = RichTextField()
    short_description = RichTextField(null=True, blank=True)
    photo = models.ForeignKey('wagtailimages.Image',
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL,
                              related_name='+')
    created_at = models.DateTimeField(auto_now_add=True)
    modified_at = models.DateTimeField(auto_now=True)

    panels = [
        FieldPanel('title'),
        FieldPanel('author'),
        FieldPanel('description'),
        FieldPanel('short_description'),
        ImageChooserPanel('photo'),
    ]

    def __unicode__(self):
        return u"%s" % self.title
Ejemplo n.º 3
0
class ContentPage(Page):
    """Abstract base class for simple content pages."""
    is_creatable = True

    class Meta:
        abstract = True

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

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

    promote_panels = Page.promote_panels + [
        ImageChooserPanel('feed_image'),
    ]

    # Default content section for determining the active nav
    @property
    def content_section(self):
        return 'registration-and-reporting'
class Testimonial(LinkFields):
    page = models.ForeignKey(
        Page,
        related_name='testimonials',
        null=True,
        blank=True
    )
    name = models.CharField(max_length=150)
    photo = models.ForeignKey(
        Image, null=True, blank=True, on_delete=models.SET_NULL
    )
    text = models.CharField(max_length=255)

    panels = [
        PageChooserPanel('page'),
        FieldPanel('name'),
        ImageChooserPanel('photo'),
        FieldPanel('text'),
        MultiFieldPanel(LinkFields.panels, "Link"),
    ]

    def __unicode__(self):
        return self.name
Ejemplo n.º 5
0
class Region(models.Model):
    name = models.CharField(max_length=128, verbose_name=("Region"))
    image = models.ForeignKey('wagtailimages.Image',
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL,
                              related_name='+')

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = 'Country Region'

    panels = [
        MultiFieldPanel(
            [
                FieldPanel('name'),
                ImageChooserPanel('image'),
            ],
            heading="country details",
        )
    ]
Ejemplo n.º 6
0
class HomePageContentItem(Orderable, LinkFields):
    page = ParentalKey('pages.HomePage', related_name='content_items')
    image = models.ForeignKey('wagtailimages.Image',
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL,
                              related_name='+')
    title = models.CharField(max_length=100)
    content = RichTextField(
        null=True,
        blank=True,
    )
    summary = RichTextField(blank=True)
    slug = models.SlugField()

    panels = [
        FieldPanel('title'),
        ImageChooserPanel('image'),
        FieldPanel('summary'),
        FieldPanel('content'),
        FieldPanel('slug'),
        MultiFieldPanel(LinkFields.panels, "Link"),
    ]
Ejemplo n.º 7
0
class Performance(Page):
    subtitle = models.CharField("Подзаголовок", blank=True, max_length=255)
    top_image = models.ForeignKey(
        "wagtailimages.Image",
        verbose_name="Заглавная картинка",
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
        related_name="+",
    )
    video = models.ForeignKey('theatre.YouTubeEmbedSnippet',
                              verbose_name="Видео с YouTube",
                              null=True,
                              blank=True,
                              related_name='+',
                              on_delete=models.SET_NULL)
    description = RichTextField("Описание", blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('subtitle', classname='full'),
        ImageChooserPanel('top_image'),
        FieldPanel('description'),
        InlinePanel('gallery_items', label="Фотогалерея"),
        SnippetChooserPanel('video'),
    ]

    search_fields = Page.search_fields + [
        index.SearchField('description'),
    ]

    objects = PageManager()
    scheduled = ScheduledPerformanceManager()

    class Meta:
        ordering = ["title"]
        verbose_name = "Спектакль"
        verbose_name_plural = "Спектакли"
Ejemplo n.º 8
0
class AlumInfo(Orderable):
    page = ParentalKey(CohortPage, related_name='participant')
    name = models.CharField(max_length=255, verbose_name="Name")
    email = models.EmailField(verbose_name="Email")
    picture = models.ForeignKey('wagtailimages.Image',
                                null=True,
                                blank=True,
                                on_delete=models.SET_NULL,
                                related_name='+')
    gravitar = models.BooleanField(
        max_length=255,
        verbose_name="Use gravitar image associated with email?")
    location = models.CharField(max_length=255,
                                blank=True,
                                verbose_name="Location (optional)")
    nick = models.CharField(max_length=255,
                            blank=True,
                            verbose_name="Chat/Forum/IRC username (optional)")
    blog = models.URLField(blank=True, verbose_name="Blog URL (optional)")
    rss = models.URLField(blank=True, verbose_name="RSS URL (optional)")
    community = models.CharField(max_length=255, verbose_name="Community name")
    project = models.CharField(max_length=255,
                               verbose_name="Project description")
    mentors = models.CharField(max_length=255, verbose_name="Mentor name(s)")
    panels = [
        FieldPanel('name'),
        FieldPanel('email'),
        ImageChooserPanel('picture'),
        FieldPanel('gravitar'),
        FieldPanel('location'),
        FieldPanel('nick'),
        FieldPanel('blog'),
        FieldPanel('rss'),
        FieldPanel('community'),
        FieldPanel('project'),
        FieldPanel('mentors'),
    ]
Ejemplo n.º 9
0
class FrontPage(RelativeURLMixin, Page):
    hero_background = models.ForeignKey('wagtailimages.Image',
                                        null=True,
                                        blank=True,
                                        on_delete=models.SET_NULL,
                                        related_name='+')
    hero = StreamField([
        ('paragraph', blocks.RichTextBlock()),
    ])

    content_panels = Page.content_panels + [
        ImageChooserPanel('hero_background'),
        StreamFieldPanel('hero'),
    ]

    @property
    def indicators(self):
        return Indicator.objects.filter(front_page=True)

    @property
    def themes(self):
        return ThemePage.objects.all()

    @property
    def blog_posts(self):
        posts = BlogPage.objects.live().order_by('-date')
        for blogpost in posts:
            blogpost.parent_title = blogpost.get_parent().title
        return posts

    @property
    def event_index(self):
        return EventsIndexPage.objects.live().first()

    @property
    def footer_link_sections(self):
        return FooterLinkSection.objects.order_by('sort_order')
Ejemplo n.º 10
0
class LocationsIndexPage(Page):
    """
    A Page model that creates an index page (a listview)
    """
    introduction = models.TextField(help_text='Text to describe the page',
                                    blank=True)
    image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
        help_text=
        'Landscape mode only; horizontal width between 1000px and 3000px.')

    # Only LocationPage objects can be added underneath this index page
    subpage_types = ['LocationPage']

    # Allows children of this indexpage to be accessible via the indexpage
    # object on templates. We use this on the homepage to show featured
    # sections of the site and their child pages
    def children(self):
        return self.get_children().specific().live()

    # Overrides the context to list all child
    # items, that are live, by the date that they were published
    # http://docs.wagtail.io/en/latest/getting_started/tutorial.html#overriding-context
    def get_context(self, request):
        context = super(LocationsIndexPage, self).get_context(request)
        context['locations'] = LocationPage.objects.descendant_of(
            self).live().order_by('title')
        return context

    content_panels = Page.content_panels + [
        FieldPanel('introduction', classname="full"),
        ImageChooserPanel('image'),
    ]
Ejemplo n.º 11
0
class GalleryPage(Page):
    """
    This is a page to list locations from the selected Collection. We use a Q
    object to list any Collection created (/admin/collections/) even if they
    contain no items. In this demo we use it for a GalleryPage,
    and is intended to show the extensibility of this aspect of Wagtail
    """

    introduction = models.TextField(help_text='Text to describe the page',
                                    blank=True)
    image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
        help_text='Landscape mode only; horizontal width between 1000px and '
        '3000px.')
    body = StreamField(BaseStreamBlock(), verbose_name="Page body", blank=True)
    collection = models.ForeignKey(
        Collection,
        limit_choices_to=~models.Q(name__in=['Root']),
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        help_text='Select the image collection for this gallery.')

    content_panels = Page.content_panels + [
        FieldPanel('introduction', classname="full"),
        StreamFieldPanel('body'),
        ImageChooserPanel('image'),
        FieldPanel('collection'),
    ]

    # Defining what content type can sit under the parent. Since it's a blank
    # array no subpage can be added
    subpage_types = []
Ejemplo n.º 12
0
class GalleryHomePage(Page):
    photo_of_the_week = models.ForeignKey("core.AffixImage",
                                          null=False,
                                          blank=False,
                                          on_delete=models.PROTECT)
    photo_title = models.TextField(blank=False, null=False)
    photo_link = models.TextField(blank=True, null=True)
    talking_album = models.ForeignKey("album.Album",
                                      null=False,
                                      blank=False,
                                      related_name='talking',
                                      on_delete=models.PROTECT)
    photo_album = models.ForeignKey("album.Album",
                                    null=False,
                                    blank=False,
                                    related_name='photo',
                                    on_delete=models.PROTECT)
    video = models.ForeignKey("article.Article",
                              null=False,
                              blank=False,
                              on_delete=models.PROTECT)

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            ImageChooserPanel('photo_of_the_week'),
            FieldPanel('photo_title'),
            FieldPanel('photo_link'),
        ]),
        FieldPanel('talking_album'),
        FieldPanel('photo_album'),
        FieldPanel('video'),
    ]

    base_form_class = GalleryHomePageAdminForm

    def __str__(self):
        return _("GalleryHomePage")
Ejemplo n.º 13
0
class BlogPage(Page):

    main_image = models.ForeignKey(ExtendedImage,
                                   null=True,
                                   blank=True,
                                   on_delete=models.SET_NULL,
                                   related_name='+')

    date = models.DateField('Post Date')
    intro = models.CharField(max_length=250)
    body = StreamField([
        ('heading', blocks.CharBlock(classname='full title')),
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('html', RawHTMLBlock()),
        ('embed', EmbedBlock()),
    ])

    search_fields = Page.search_fields + (
        index.SearchField('intro'),
        index.SearchField('body'),
    )

    def get_absolute_url(self):
        return self.full_url

    @property
    def blog_index(self):
        return self.get_ancestors().type(BlogIndexPage).last()

    content_panels = Page.content_panels + [
        FieldPanel('date'),
        ImageChooserPanel('main_image'),
        FieldPanel('intro'),
        StreamFieldPanel('body'),
        InlinePanel('related_links', label='Related Links')
    ]
Ejemplo n.º 14
0
class Post(Page):
    cover = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )
    body = StreamField(PostStreamBlock())
    intro = models.TextField(max_length=600)
    tags = ClusterTaggableManager(through=PostTag, blank=True)
    date = models.DateField(_('Post date'))

    search_fields = Page.search_fields + [
        index.SearchField('body'),
    ]

    content_panels = Page.content_panels + [
        FieldPanel('intro'),
        ImageChooserPanel('cover'),
        FieldPanel('tags'),
        StreamFieldPanel('body'),
        FieldPanel('date'),
    ]
Ejemplo n.º 15
0
class FormPage(AbstractEmailForm):
    image = models.ForeignKey('wagtailimages.Image',
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL,
                              related_name='+')
    body = StreamField(BaseStreamBlock())
    thank_you_text = RichTextField(blank=True)

    # Note how we include the FormField object via an InlinePanel using the
    # related_name value
    content_panels = AbstractEmailForm.content_panels + [
        ImageChooserPanel('image'),
        StreamFieldPanel('body'),
        InlinePanel('form_fields', label="Form fields"),
        FieldPanel('thank_you_text', classname="full"),
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('from_address', classname="col6"),
                FieldPanel('to_address', classname="col6"),
            ]),
            FieldPanel('subject'),
        ], "Email"),
    ]
Ejemplo n.º 16
0
class TeamPage(Page):
    avatar = models.ForeignKey('wagtailimages.Image',
                               related_name='+',
                               on_delete=models.SET_NULL,
                               null=True,
                               blank=True)
    name = models.TextField(max_length=255, default='')
    designation = models.TextField(max_length=255, default='')
    description = models.TextField(max_length=255, default='')
    facebook_link = models.TextField(max_length=255, default='')
    twitter_link = models.TextField(max_length=255, default='')
    google_link = models.TextField(max_length=255, default='')

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            ImageChooserPanel('avatar'),
            FieldPanel('name'),
            FieldPanel('designation'),
            FieldPanel('description'),
            FieldPanel('facebook_link'),
            FieldPanel('twitter_link'),
            FieldPanel('google_link'),
        ], 'Team'),
    ]
Ejemplo n.º 17
0
class ListaDeVehiculos(Page):
    intro = RichTextField(blank=True)
    logo = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    def get_context(self, request):
    # Update context to include only published posts, ordered by reverse-chron
        context = super(ListaDeVehiculos, self).get_context(request)
        vehiculos = self.get_children().live().order_by('first_published_at')
        context['vehiculos'] = vehiculos
        return context

    content_panels = Page.content_panels + [
        FieldPanel('intro', classname="full"),
        ImageChooserPanel('logo'),
    ]

    # parent_page_types = []
    subpage_types = ['DetalleDeVehiculo']
Ejemplo n.º 18
0
class TeamPage(Page):
    profile_picture = models.ForeignKey('wagtailimages.Image',
                                        related_name='+',
                                        on_delete=models.SET_NULL,
                                        null=True,
                                        blank=False)
    name = models.CharField(max_length=100, null=True, blank=True)
    designation = models.CharField(max_length=100, null=True, blank=True)
    twitter_link = models.CharField(max_length=100, null=True, blank=True)
    facebook_link = models.CharField(max_length=100, null=True, blank=True)
    linkedin_link = models.CharField(max_length=100, null=True, blank=True)

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            ImageChooserPanel('profile_picture'),
            FieldPanel('name'),
            FieldPanel('designation'),
            FieldPanel('twitter_link'),
            FieldPanel('facebook_link'),
            FieldPanel('linkedin_link'),
        ], 'Team'),
    ]

    subpage_types = []
Ejemplo n.º 19
0
class FabricationPage(Page):
    video_hd_url = models.URLField(blank=True,
        help_text='High Definition URL from a video streaming service such as Vimeo.')
    video_sd_url = models.URLField(blank=True,
        help_text='Standard Definition URL from a video streaming service such as Vimeo.')
    video_poster = models.ForeignKey(
        'wagtailimages.Image', on_delete=models.PROTECT, related_name='+',
        blank=True, null=True, help_text="Still frame from video to show while loading"
    )
    fabrication_content = StreamField(FabricationStreamBlock())
    

    content_panels = Page.content_panels + [
        FieldPanel('video_hd_url'),
        FieldPanel('video_sd_url'),
        ImageChooserPanel('video_poster'),
        StreamFieldPanel('fabrication_content'),
    ]
        
    parent_page_types = ['home.HomePage'] 
    subpage_types = ['fabrication.FabricationMaterialPage']

    def get_context(self, request):
        context = super(FabricationPage, self).get_context(request)
        materials = FabricationMaterialPage.objects.live().child_of(self)

        # make the variable 'Materials' available on the template
        context['materials'] = materials

        return context

    @classmethod
    def can_create_at(cls, parent):
        # You can only create one of these!
        return super(FabricationPage, cls).can_create_at(parent) \
            and not cls.objects.exists()
Ejemplo n.º 20
0
class Generica(Page):
    """
    Página genérica 
    """

    introduccion = models.TextField(
        help_text='Texto para describir la página',
        blank=True)
    imagen = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
        help_text='Landscape mode only; horizontal width between 1000px and 3000px.'
    )
    body = StreamField(
        BaseStreamBlock(), verbose_name="Cuerpo de la página", blank=True
    )
    content_panels = Page.content_panels + [
        FieldPanel('introduccion', classname="full"),
        StreamFieldPanel('body'),
        ImageChooserPanel('imagen'),
    ]
class NavPage(Page):

    # Database fields
    nav_title = RichTextField(default='')
    body = StreamField([('heading', blocks.CharBlock(classname="full title")),
                        ('paragraph', blocks.RawHTMLBlock())])
    date = models.DateField("Post date")
    feed_image = models.ForeignKey('wagtailimages.Image',
                                   null=True,
                                   blank=True,
                                   on_delete=models.SET_NULL,
                                   related_name='+')

    # Search index configuraiton

    search_fields = Page.search_fields + (
        index.SearchField('body'),
        index.FilterField('date'),
    )

    # Editor panels configuration

    content_panels = Page.content_panels + [
        FieldPanel('nav_title'),
        FieldPanel('date'),
        StreamFieldPanel('body'),
    ]

    promote_panels = [
        MultiFieldPanel(Page.promote_panels, "Common page configuration"),
        ImageChooserPanel('feed_image'),
    ]

    # Parent page / subpage type rules

    parent_page_types = ['SectionPage']
Ejemplo n.º 22
0
class NewsPage(Page):
    date = models.DateField("Post date")
    name = models.CharField(blank=True, max_length=250)
    image = models.ForeignKey('wagtailimages.Image',
                              on_delete=models.SET_NULL,
                              related_name='+',
                              null=True,
                              blank=True,
                              verbose_name="Миниатюра")
    body = RichTextField(editor='tinymce', blank=True, verbose_name="Текст")

    search_fields = Page.search_fields + [
        index.SearchField('body'),
    ]
    sidebar = RichTextField(editor='tinymce', blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('date'),
        FieldPanel('name'),
        ImageChooserPanel('image'),
        FieldPanel('body', classname="full"),
        FieldPanel('sidebar'),
        InlinePanel('related_pages', label="Связанные новости"),
    ]
Ejemplo n.º 23
0
class SocialMediaSettings(BaseSetting):
    twitter_handle = models.CharField(
        max_length=255,
        blank=True,
        help_text='Your Twitter username without the @, e.g. katyperry',
    )
    facebook_app_id = models.CharField(
        max_length=255,
        blank=True,
        help_text='Your Facebook app ID.',
    )
    default_sharing_text = models.CharField(
        max_length=255,
        blank=True,
        help_text=
        'Default sharing text to use if social text has not been set on a page.',
    )
    site_name = models.CharField(
        max_length=255,
        blank=True,
        default='Girl Effect',
        help_text='Site name, used by Open Graph.',
    )
    default_sharing_image = models.ForeignKey(CustomImage,
                                              null=True,
                                              blank=True,
                                              on_delete=models.SET_NULL,
                                              related_name='+')

    panels = [
        FieldPanel('twitter_handle'),
        FieldPanel('facebook_app_id'),
        FieldPanel('default_sharing_text'),
        FieldPanel('site_name'),
        ImageChooserPanel('default_sharing_image')
    ]
Ejemplo n.º 24
0
class Personal(Orderable):
    
    nombre = models.CharField("Nombre", max_length=255)
    imagen = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )
    biografia = RichTextField(blank=True)
    descripcion = RichTextField(blank=True)
    mas_info = models.URLField("URL mas info", blank=True)

    panels = [
        FieldPanel('nombre'),
        FieldPanel('biografia'),
        FieldPanel('descripcion'),
        FieldPanel('mas_info'),

        ImageChooserPanel('imagen'),
    ]
    class Meta:
        abstract = True
Ejemplo n.º 25
0
class AbstractCarouselItem(AbstractLinkFields):
    image = models.ForeignKey('wagtailimages.Image',
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL,
                              related_name='+')
    embed_url = models.URLField("Embed URL", blank=True)
    caption = models.CharField(max_length=255, blank=True)

    api_fields = (
        'image',
        'embed_url',
        'caption',
    ) + AbstractLinkFields.api_fields

    panels = [
        ImageChooserPanel('image'),
        FieldPanel('embed_url'),
        FieldPanel('caption'),
        MultiFieldPanel(AbstractLinkFields.panels, "Link"),
    ]

    class Meta:
        abstract = True
Ejemplo n.º 26
0
class Advert(LinkFields):
    page = models.ForeignKey(Page,
                             related_name='adverts',
                             null=True,
                             blank=True)
    title = models.CharField(max_length=150, null=True)
    image = models.ForeignKey(Image,
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL)
    button_text = models.CharField(max_length=150, null=True)
    text = RichTextField(blank=True)

    panels = [
        PageChooserPanel('page'),
        FieldPanel('title'),
        ImageChooserPanel('image'),
        FieldPanel('text'),
        FieldPanel('button_text'),
        MultiFieldPanel(LinkFields.panels, "Link"),
    ]

    def __unicode__(self):
        return self.title
Ejemplo n.º 27
0
class BlogPage(Page):
    date = models.DateField("Post date")
    intro = models.CharField(max_length=250, default=None)
    body = RichTextField(blank=True)

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

    search_fields = Page.search_fields + [
        index.SearchField('intro'),
        index.SearchField('body'),
    ]

    content_panels = Page.content_panels + [
        FieldPanel('date'),
        FieldPanel('intro'),
        FieldPanel('body', classname='full'),
        ImageChooserPanel('main_image'),
    ]
Ejemplo n.º 28
0
class EventPageSpeaker(Orderable, AbstractLinkFields):
    page = ParentalKey('EventPage',
                       related_name='speakers',
                       on_delete=models.CASCADE)
    first_name = models.CharField("Name", max_length=255, blank=True)
    last_name = models.CharField("Surname", max_length=255, blank=True)
    image = models.ForeignKey('wagtailimages.Image',
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL,
                              related_name='+')

    api_fields = (
        'first_name',
        'last_name',
        'image',
    )

    panels = [
        FieldPanel('first_name'),
        FieldPanel('last_name'),
        ImageChooserPanel('image'),
        MultiFieldPanel(AbstractLinkFields.panels, "Link"),
    ]
Ejemplo n.º 29
0
class SeriesArticleLink(Orderable, models.Model):
    override_image = models.ForeignKey(
        'images.AttributedImage',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
        help_text="This field is optional. If not provided, the image will be "
                  "pulled from the article page automatically. This field "
                  "allows you to override the automatic image."
    )
    override_text = RichTextField(
        blank=True,
        default="",
        help_text="This field is optional. If not provided, the text will be "
                  "pulled from the article page automatically. This field "
                  "allows you to override the automatic text."
    )
    article = models.ForeignKey(
        "ArticlePage",
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='series_links'
    )
    series = ParentalKey(
        "SeriesPage",
        related_name='related_article_links'
    )

    panels = [
        PageChooserPanel("article", 'articles.ArticlePage'),
        FieldPanel("override_text"),
        ImageChooserPanel("override_image"),

    ]
Ejemplo n.º 30
0
class MethodPage(Page):
    overview = models.TextField("Краткое описание", max_length=250)
    image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
        verbose_name="картинка",
    )
    body = StreamField(
        BaseContentBlock,
        verbose_name='Основной текстовый блок',
        blank=True,
    )

    content_panels = Page.content_panels + [
        ImageChooserPanel('image'),
        FieldPanel('overview', classname="full"),
        StreamFieldPanel('body'),
    ]
    parent_page_types = ['methods.MethodIndexPage']
    subpage_types = []

    class Meta:
        verbose_name = 'Методика'
        verbose_name_plural = 'Методика'

    def get_context(self, request, *args, **kwargs):
        """
        Add some random MethodPages to the context.
        """
        context = super(MethodPage, self).get_context(request, *args, **kwargs)
        random_methods = MethodPage.objects.order_by('?').live()[:2]
        context['random_methods'] = random_methods
        return context