Ejemplo n.º 1
0
class Memorial(Page):
    given_name = models.CharField(
        max_length=255,
        default="",
        help_text="Enter the given name for a person.",
    )
    family_name = models.CharField(max_length=255, blank=True, default="")
    date_of_birth = models.DateField()
    date_of_death = models.DateField()
    dates_are_approximate = models.BooleanField()
    memorial_minute = RichTextField(blank=True)
    memorial_meeting = models.ForeignKey(
        to="contact.Meeting",
        on_delete=models.PROTECT,
        related_name="memorial_minutes"
    )

    def full_name(self):
        return f"{ self.given_name } { self.family_name }"

    content_panels = [
        FieldPanel("given_name"),
        FieldPanel("family_name"),
        FieldPanel("date_of_birth", widget=DatePickerInput()),
        FieldPanel("date_of_death", widget=DatePickerInput()),
        FieldPanel("dates_are_approximate"),
        FieldPanel("memorial_minute"),
        PageChooserPanel("memorial_meeting"),
    ]

    parent_page_types = [
        "MemorialIndexPage",
    ]

    def save(self, *args, **kwargs):
        self.title = self.full_name()

        super(Memorial, self).save(*args, **kwargs)

    search_fields = [
        index.SearchField("given_name", partial_match=True),
        index.SearchField("family_name", partial_match=True),
    ]
Ejemplo n.º 2
0
class MenuItem(Orderable):
    link_title = models.CharField(
        blank=True,
        max_length=50,
    )
    link_page = models.ForeignKey(
        'wagtailcore.Page',
        null=True,
        blank=True,
        related_name='+',
        on_delete=models.CASCADE,
    )

    panels = [
        FieldPanel("link_title"),
        PageChooserPanel("link_page"),
    ]

    page = ParentalKey("Menu", related_name="menu_items")
Ejemplo n.º 3
0
class ClickThrough(Page):
    target_page = models.ForeignKey('content.Page',
                                    models.SET_NULL,
                                    'click_throughs',
                                    blank=True,
                                    null=True)
    target_link = models.TextField(blank=True, default='')

    @property
    def public_path(self):
        if self.target_page:
            return self.target_page.public_path

        return self.target_link

    content_panels = Page.content_panels + [
        PageChooserPanel('target_page'),
        FieldPanel('target_link'),
    ]
Ejemplo n.º 4
0
class MenuItem(Orderable):

    link_title = models.CharField(
        max_length=128,
        blank=True,
    )
    link_page = models.ForeignKey(
        "wagtailcore.Page",
        blank=True,
        null=True,
        related_name="+",
        on_delete=models.SET_NULL,
    )
    open_in_new_tab = models.BooleanField(
        blank=True,
        default=False,
    )
    page = ParentalKey(
        Menu,
        related_name="menu_items",
    )

    panels = [
        FieldPanel("link_title"),
        PageChooserPanel("link_page"),
        FieldPanel("open_in_new_tab"),
    ]

    @property
    def link(self):
        if self.link_page:
            return self.link_page.url
        else:
            return "#"

    @property
    def title(self):
        if self.link_title:
            return self.link_title
        elif self.link_page:
            return self.link_page.title
        else:
            return "Missing Title"
Ejemplo n.º 5
0
class ToolsMenuItem(Orderable, models.Model):
    model = ParentalKey('utils.SecondaryMenu', related_name='tools_menu_items')
    page = models.ForeignKey('wagtailcore.Page',
                             related_name='+',
                             null=True,
                             blank=True,
                             on_delete=models.SET_NULL)
    link = models.URLField(blank=True)
    text = models.CharField(max_length=255, blank=True)

    @property
    def url(self):
        return self.link or getattr(self.page, 'url', '')

    @property
    def title(self):
        return self.text or getattr(self.page, 'title', '')

    panels = [PageChooserPanel('page'), FieldPanel('link'), FieldPanel('text')]
class PageRedirection(Page):
    """
    Unlike wagtail redirects that do not respect the page tree.
    This page type can be placed anywhere in the page explorer and it will redirect to the given page.
    """
    redirect_to_page = models.ForeignKey('wagtailcore.Page',
                                         related_name='+',
                                         on_delete=models.PROTECT)

    # show in menu ticked by default
    show_in_menus_default = True

    # editor panels configuration
    content_panels = Page.content_panels + [
        PageChooserPanel('redirect_to_page'),
    ]

    def serve(self, request):
        return redirect(self.redirect_to_page.url, permanent=False)
Ejemplo n.º 7
0
class EntryAbstract(models.Model):
    body = RichTextField(verbose_name=_('body'))
    tags = ClusterTaggableManager(through='puput.TagEntryPage', blank=True)
    date = models.DateTimeField(verbose_name=_("Post date"),
                                default=datetime.datetime.today)
    header_image = models.ForeignKey(get_image_model_path(),
                                     verbose_name=_('Header image'),
                                     null=True,
                                     blank=True,
                                     on_delete=models.SET_NULL,
                                     related_name='+')
    categories = models.ManyToManyField('puput.Category',
                                        through='puput.CategoryEntryPage',
                                        blank=True)
    excerpt = RichTextField(
        verbose_name=_('excerpt'),
        blank=True,
        help_text=_(
            "Entry excerpt to be displayed on entries list. "
            "If this field is not filled, a truncate version of body text will be used."
        ))
    num_comments = models.IntegerField(default=0, editable=False)

    content_panels = [
        MultiFieldPanel([
            FieldPanel('title', classname="title"),
            ImageChooserPanel('header_image'),
            FieldPanel('body', classname="full"),
            FieldPanel('excerpt', classname="full"),
        ],
                        heading=_("Content")),
        MultiFieldPanel([
            FieldPanel('tags'),
            InlinePanel('entry_categories', label=_("Categories")),
            InlinePanel('related_entrypage_from',
                        label=_("Related Entries"),
                        panels=[PageChooserPanel('entrypage_to')]),
        ],
                        heading=_("Metadata")),
    ]

    class Meta:
        abstract = True
Ejemplo n.º 8
0
class ResetNetworkHomePageOpenCalls(Orderable):
    open_calls_link = ParentalKey(
        'reset_network_home.ResetNetworkHomePage',
        related_name='reset_network_home_page_open_calls',
        on_delete=models.CASCADE)

    open_call_link_page = models.ForeignKey('wagtailcore.Page',
                                            verbose_name='Open calls Page',
                                            help_text='The page to link to',
                                            null=True,
                                            blank=False,
                                            related_name='+',
                                            on_delete=models.SET_NULL)

    panels = [
        PageChooserPanel(
            'open_call_link_page',
            page_type='reset_network_open_calls.ResetNetworkOpenCallPage')
    ]
Ejemplo n.º 9
0
class Author(index.Indexed, models.Model):
    person_page = models.OneToOneField('people.PersonPage',
                                       on_delete=models.SET_NULL,
                                       null=True,
                                       blank=True,
                                       related_name='+')

    name = models.CharField(max_length=255, blank=True)
    role = models.CharField(max_length=255, blank=True)
    image = models.ForeignKey('torchbox.TorchboxImage',
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL,
                              related_name='+')

    def update_manual_fields(self, person_page):
        self.name = person_page.title
        self.role = person_page.role
        self.image = person_page.image

    def clean(self):
        if not self.person_page and not self.name:
            raise ValidationError(
                {'person_page': "You must set either 'Person page' or 'Name'"})

        if self.person_page:
            self.update_manual_fields(self.person_page)

    def __str__(self):
        return self.name

    search_fields = [
        index.SearchField('name'),
    ]

    panels = [
        PageChooserPanel('person_page'),
        MultiFieldPanel([
            FieldPanel('name'),
            FieldPanel('role'),
            ImageChooserPanel('image'),
        ], "Manual fields"),
    ]
Ejemplo n.º 10
0
class MenuItemContentRow(Orderable):
    row_title = models.CharField(max_length=50)
    row_link = models.URLField(blank=True, null=True)

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

    menu_item = ParentalKey("MenuItemContentColumn", related_name="column_row")

    panels = [
        FieldPanel('row_title'),
        FieldPanel('row_link'),
        PageChooserPanel("row_page"),
    ]
Ejemplo n.º 11
0
class ServiceIndexPageService(Orderable):
    page = ParentalKey('services.ServiceIndexPage', related_name='services')
    title = models.TextField()
    svg = models.TextField(null=True)
    description = models.TextField()
    link = models.ForeignKey(
        'services.ServicePage',
        on_delete=models.SET_NULL,
        related_name='+',
        blank=True,
        null=True,
    )

    panels = [
        FieldPanel('title'),
        FieldPanel('description'),
        PageChooserPanel('link'),
        FieldPanel('svg')
    ]
Ejemplo n.º 12
0
class PageTopic(models.Model):
    page = ParentalKey(
        "content.ContentPage",
        on_delete=models.CASCADE,
        related_name="topics",
    )

    topic = models.ForeignKey(
        "working_at_dit.Topic",
        on_delete=models.CASCADE,
        related_name="topic_Pages",
    )

    panels = [
        PageChooserPanel("topic"),
    ]

    class Meta:
        unique_together = ("page", "topic")
Ejemplo n.º 13
0
class MagazineArticle(Page):
    teaser = RichTextField(blank=True)
    body = RichTextField(blank=True)

    department = models.ForeignKey(MagazineDepartment,
                                   null=True,
                                   blank=True,
                                   on_delete=models.SET_NULL,
                                   related_name="articles")

    tags = ClusterTaggableManager(through=MagazineArticleTag, blank=True)

    search_template = "search/magazine_article.html"

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

    content_panels = Page.content_panels + [
        FieldPanel("teaser", classname="full"),
        FieldPanel("body", classname="full"),
        InlinePanel(
            "authors",
            heading="Authors",
            help_text=
            "Select one or more authors, who contributed to this article",
        ),
        MultiFieldPanel(
            [
                PageChooserPanel("department", "magazine.MagazineDepartment"),
                FieldPanel("tags"),
            ],
            heading="Article information",
        ),
    ]

    parent_page_types = ["MagazineIssue"]
    subpage_types = []

    def get_sitemap_urls(self):
        return [{
            "location": self.full_url,
            "lastmod": self.latest_revision_created_at,
            "priority": 1,
        }]
Ejemplo n.º 14
0
class ResetNetworkWorkPage(ResetNetworkBasePage):

    class Meta:
        verbose_name = "Reset Network Work Page"

    parent_page_types = ['reset_network_home.ResetNetworkHomePage']
    subpage_types = []

    content_heading = models.CharField(verbose_name='Heading', max_length=255, blank=False)
    content_text = models.TextField(verbose_name='Text', blank=True)
    content_long_text = RichTextField(verbose_name='Text', blank=True)

    region_heading = models.CharField(verbose_name='Heading', max_length=255, null=True, blank=True)

    content_bottom_heading = models.CharField(verbose_name='Heading', max_length=255, blank=True)
    content_bottom_text = models.TextField(verbose_name='Text', blank=True)
    content_bottom_image = models.ForeignKey('images.CustomImage', verbose_name='Image', null=True, blank=True,
                                             related_name='+', on_delete=models.SET_NULL)
    content_bottom_link = models.ForeignKey('wagtailcore.Page', verbose_name='Link', null=True, blank=True, related_name='+',
                                            on_delete=models.PROTECT)
    content_bottom_link_text = models.CharField(verbose_name='Link text', max_length=255, blank=True)

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel('content_heading'),
            FieldPanel('content_text'),
            FieldPanel('content_long_text'),
        ], heading='Content'),
        MultiFieldPanel([
            InlinePanel('reset_network_work_pillar', label='Pillar', heading='Pillar')
        ], heading='content - Pillars'),
        MultiFieldPanel([
            FieldPanel('region_heading'),
            InlinePanel('reset_network_work_region', label='Region', heading='Region')
        ], heading='Content - Regions'),
        MultiFieldPanel([
            FieldPanel('content_bottom_heading'),
            FieldPanel('content_bottom_text'),
            ImageChooserPanel('content_bottom_image'),
            PageChooserPanel('content_bottom_link'),
            FieldPanel('content_bottom_link_text')
        ], heading='Content bottom'),
    ]
Ejemplo n.º 15
0
    def setUp(self):
        model = PageChooserModel  # a model with a foreign key to Page which we want to render as a page chooser

        # a PageChooserPanel class that works on PageChooserModel's 'page' field
        self.edit_handler = (ObjectList([PageChooserPanel('page')])
                             .bind_to_model(PageChooserModel))
        self.my_page_chooser_panel = self.edit_handler.children[0]

        # build a form class containing the fields that MyPageChooserPanel wants
        self.PageChooserForm = self.edit_handler.get_form_class()

        # a test instance of PageChooserModel, pointing to the 'christmas' page
        self.christmas_page = Page.objects.get(slug='christmas')
        self.events_index_page = Page.objects.get(slug='events')
        self.test_instance = model.objects.create(page=self.christmas_page)

        self.form = self.PageChooserForm(instance=self.test_instance)
        self.page_chooser_panel = self.my_page_chooser_panel.bind_to_instance(
            instance=self.test_instance, form=self.form)
Ejemplo n.º 16
0
class MenuItem(Orderable):
    link_title = models.CharField(
        blank=True,
        null=True,
        max_length=50,
    )
    link_url = models.CharField(
        max_length=500,
        blank=True,
    )
    link_page = models.ForeignKey(
        "wagtailcore.Page",
        null=True,
        blank=True,
        related_name="+",
        on_delete=models.CASCADE,
    )
    open_in_new_tab = models.BooleanField(default=False, blank=True)

    page = ParentalKey("Menu", related_name="menu_items")

    panels = [
        FieldPanel("link_title"),
        FieldPanel("link_url"),
        PageChooserPanel("link_page"),
        FieldPanel("open_in_new_tab"),
    ]

    @property
    def link(self):
        if self.link_page:
            return self.link_page.url
        elif self.link_url:
            return self.link_url
        return '#'

    @property
    def title(self):
        if self.link_page and not self.link_title:
            return self.link_page.title
        elif self.link_title:
            return self.link_title
        return 'Missing Title'
Ejemplo n.º 17
0
class MagazineArticleAuthor(Orderable):
    article = ParentalKey(
        "magazine.MagazineArticle",
        null=True,
        on_delete=models.CASCADE,
        related_name="authors",
    )
    author = models.ForeignKey(
        "wagtailcore.Page",
        null=True,
        on_delete=models.CASCADE,
        related_name="articles_authored",
    )

    panels = [
        PageChooserPanel(
            "author",
            ["contact.Person", "contact.Meeting", "contact.Organization"])
    ]
Ejemplo n.º 18
0
class Contact(WagtailCaptchaEmailForm):
    intro = RichTextField(blank=True)
    main_image = models.ForeignKey('home.homeImage',
                                   null=True,
                                   blank=True,
                                   on_delete=models.SET_NULL,
                                   related_name='+')
    landing_image = models.ForeignKey('home.homeImage',
                                      null=True,
                                      blank=True,
                                      on_delete=models.SET_NULL,
                                      related_name='+')
    thank_you_text = models.CharField(max_length=255, help_text='e.g. Thanks!')
    thank_you_follow_up = models.CharField(max_length=255,
                                           help_text='e.g. We\'ll be in touch')
    landing_page_button_title = models.CharField(max_length=255, blank=True)
    landing_page_button_link = models.ForeignKey('wagtailcore.Page',
                                                 null=True,
                                                 blank=True,
                                                 related_name='+',
                                                 on_delete=models.SET_NULL)

    class Meta:
        verbose_name = "Contact Page"

    content_panels = [
        FieldPanel('title', classname="full title"),
        FieldPanel('intro', classname="full"),
        ImageChooserPanel('main_image'),
        InlinePanel('form_fields', label="Form fields"),
        MultiFieldPanel([
            FieldPanel('to_address', classname="full"),
            FieldPanel('from_address', classname="full"),
            FieldPanel('subject', classname="full"),
        ], "Email"),
        MultiFieldPanel([
            ImageChooserPanel('landing_image'),
            FieldPanel('thank_you_text'),
            FieldPanel('thank_you_follow_up'),
            PageChooserPanel('landing_page_button_link'),
            FieldPanel('landing_page_button_title'),
        ], "Landing page"),
    ]
Ejemplo n.º 19
0
class LibraryItemAuthor(Orderable):
    library_item = ParentalKey(
        "library.LibraryItem",
        null=True,
        on_delete=models.CASCADE,
        related_name="authors",
    )
    author = models.ForeignKey("wagtailcore.Page",
                               null=True,
                               on_delete=models.CASCADE,
                               related_name="library_items_authored")

    panels = [
        PageChooserPanel("author", [
            "contact.Person",
            "contact.Meeting",
            "contact.Organization",
        ])
    ]
Ejemplo n.º 20
0
class HomePage(Page):
    """Home page model."""

    templates = "templates/home_page.html"
    # max_count = 1 # only one webpage instance

    # fields cannot be blank in the form, but in database null is OK
    banner_title = models.CharField(max_length=100, blank=False, null=True)
        # Note: models is specific to Django, django.db := models
    banner_subtitle = RichTextField(features=["bold", "italic"]) # wagtail specific
    banner_image = models.ForeignKey(
        "wagtailimages.Image", 
        # classname of the image, see wagtail documentation
        null=True,
        blank=False,
        on_delete=models.SET_NULL,
        related_name="+"
    )
    # cta: banner call to action, link to another page 
    # link to another wagtail page we have not created yet
    banner_cta = models.ForeignKey(
        "wagtailcore.Page",
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name="+"
    )
    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel("banner_title"),
            FieldPanel("banner_subtitle"),
            ImageChooserPanel("banner_image"),
            PageChooserPanel("banner_cta"),  
        ], heading="Banner Options"),             
        MultiFieldPanel([
            InlinePanel("carousel_images", max_num=6, min_num=0, label="Image"),
        ], heading="Caroursel images")
    ]

    class Meta:

        verbose_name = "Home Page"
        verbose_name_plural = "Home Pages"
Ejemplo n.º 21
0
    def test_override_page_type(self):
        # Model has a foreign key to Page, but we specify EventPage in the PageChooserPanel
        # to restrict the chooser to that page type
        my_page_object_list = ObjectList([
            PageChooserPanel('page', 'tests.EventPage')
        ]).bind_to(model=EventPageChooserModel)
        my_page_chooser_panel = my_page_object_list.children[0]
        PageChooserForm = my_page_object_list.get_form_class()
        form = PageChooserForm(instance=self.test_instance)
        page_chooser_panel = my_page_chooser_panel.bind_to(
            instance=self.test_instance, form=form, request=self.request)

        result = page_chooser_panel.render_as_field()
        expected_js = 'createPageChooser("{id}", ["{model}"], {parent}, false, null);'.format(
            id="id_page",
            model="tests.eventpage",
            parent=self.events_index_page.id)

        self.assertIn(expected_js, result)
Ejemplo n.º 22
0
class HomepageFeaturedBlogs(WagtailOrderable, models.Model):
    page = ParentalKey(
        'wagtailpages.Homepage',
        related_name='featured_blogs',
    )
    blog = models.ForeignKey('BlogPage',
                             on_delete=models.CASCADE,
                             related_name='+')
    panels = [
        PageChooserPanel('blog'),
    ]

    class Meta:
        verbose_name = 'blog'
        verbose_name_plural = 'blogs'
        ordering = ['sort_order']  # not automatically inherited!

    def __str__(self):
        return self.page.title + '->' + self.blog.title
Ejemplo n.º 23
0
class GridIndexGridItemRelationship(Orderable, models.Model):
    """
    Allows the content creator to associate Grid Items on a
    Grid Index Page.
    """

    grid_relationship = ParentalKey(
        "GridIndexPage",
        related_name="grid_index_grid_item_relationship",
        on_delete=models.CASCADE,
    )
    grid_item = models.ForeignKey(
        "GridItem",
        related_name="+",
        help_text="Add a grid item to the page",
        verbose_name="Grid Items",
        on_delete=models.CASCADE,
    )
    panels = [PageChooserPanel("grid_item")]
Ejemplo n.º 24
0
class HomePage(Page):
    """Home page model."""

    template = "home/home_page.html"
    max_count = 1

    body = StreamField(
        [
            ("full_richtext", blocks.RichtextBlock()),
            ("simple_richtext", blocks.SimpleRichtextBlock()),
            ("cards", blocks.CardBlock()),
            ("cta", blocks.CTABlock()),
        ],
        null=True,
        blank=True,
    )

    banner_title = models.CharField(max_length=100, blank=True, null=True)
    banner_subtitle = RichTextField(blank=True, features=["bold", "italic"])
    banner_image = models.ForeignKey("wagtailimages.Image",
                                     null=True,
                                     blank=True,
                                     on_delete=models.SET_NULL,
                                     related_name="+")
    banner_cta = models.ForeignKey("wagtailcore.Page",
                                   null=True,
                                   blank=True,
                                   on_delete=models.SET_NULL,
                                   related_name="+")

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

    class Meta:

        verbose_name = "Home Page"
        verbose_name_plural = "Home Pages"
Ejemplo n.º 25
0
class MenuItem(Orderable):

    page = ParentalKey("Menu", related_name="menu_items")

    link_url = models.CharField(max_length=500, blank=True)
    link_page = models.ForeignKey(
        "wagtailcore.Page",
        null=True,
        blank=True,
        related_name="+",
        on_delete=models.CASCADE,
    )
    link_title = models.CharField(max_length=50,
                                  blank=True,
                                  null=True,
                                  verbose_name="Title(Option)",
                                  help_text="リンク先のページタイトルとは別のリンク名を付けたい時のみ")
    open_in_new_tab = models.BooleanField(default=False, blank=True)

    panels = [
        PageChooserPanel("link_page"),
        FieldPanel("link_url"),
        FieldPanel("link_title"),
        FieldPanel("open_in_new_tab"),
    ]

    @property
    def link(self):
        # def link(self) -> str:  ## to always return string
        if self.link_page:
            return self.link_page.url
        elif self.link_url:
            return self.link_url
        return '#'

    @property
    def title(self):
        if self.link_page and not self.link_title:
            return self.link_page.title
        elif self.link_title:
            return self.link_title
        return 'Missing Title'
Ejemplo n.º 26
0
class EntryAbstract(models.Model):
    body = RichTextField(verbose_name='тело')
    tags = ClusterTaggableManager(through='blog.TagEntryPage', blank=True)
    date = models.DateTimeField(verbose_name="Дата добавления",
                                default=datetime.datetime.today)
    header_image = models.ForeignKey(get_image_model_path(),
                                     verbose_name='Изображение в шапке',
                                     null=True,
                                     blank=True,
                                     on_delete=models.SET_NULL,
                                     related_name='+')
    categories = models.ManyToManyField('blog.Category',
                                        through='blog.CategoryEntryPage',
                                        blank=True)
    excerpt = RichTextField(
        verbose_name='резюме',
        blank=True,
        help_text="Резюме отображается в списке статей. "
        "Если это поле не заполнено, будет использован отрывок из текста статьи."
    )
    num_comments = models.IntegerField(default=0, editable=False)

    content_panels = [
        MultiFieldPanel([
            FieldPanel('title', classname="title"),
            ImageChooserPanel('header_image'),
            FieldPanel('body', classname="full"),
            FieldPanel('excerpt', classname="full"),
        ],
                        heading="Контент"),
        MultiFieldPanel([
            FieldPanel('tags'),
            InlinePanel('entry_categories', label="Категории"),
            InlinePanel('related_entrypage_from',
                        label="Связанные статьи",
                        panels=[PageChooserPanel('entrypage_to')]),
        ],
                        heading="Метаданные"),
    ]

    class Meta:
        abstract = True
Ejemplo n.º 27
0
class PortfolioItem(Orderable):
    portfolio = ParentalKey(
        'cms.Portfolio',
        related_name='portfolio_items',
        null=True,
        blank=True
    )
    text = models.CharField(max_length=255)
    image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )
    link = models.ForeignKey(
        'cms.ModulePage',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
    )

    panels = [
        FieldPanel('text'),
        ImageChooserPanel('image'),
        PageChooserPanel('link')
    ]

    api_fields = [
        APIField('text'),
        APIField('image'),
        APIField('link'),
    ]

    def __str__(self):
        return self.category.text

    class Meta(ClusterableModel.Meta):
        verbose_name = 'Portfolio Item'
        verbose_name_plural = 'Portfolio Items'
        ordering = ['sort_order']
Ejemplo n.º 28
0
class MultimediaListPageFeaturedMultimedia(Orderable):
    multimedia_list_page = ParentalKey(
        'multimedia.MultimediaListPage',
        related_name='featured_multimedia',
    )
    multimedia_page = models.ForeignKey(
        'wagtailcore.Page',
        null=False,
        blank=False,
        on_delete=models.CASCADE,
        related_name='+',
        verbose_name='Multimedia',
    )

    panels = [
        PageChooserPanel(
            'multimedia_page',
            ['multimedia.MultimediaPage'],
        )
    ]
Ejemplo n.º 29
0
class FeaturedStory(models.Model):
    """ A featured story holds a reference to the story and can be set
    in the snippets editor"""
    story = models.ForeignKey(
        "wagtailcore.Page", 
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name="+"
    )

    panels = [
        PageChooserPanel('story', 'news.StoryPage'),
    ]

    def __str__(self):
        return self.story.title

    class Meta:
        verbose_name_plural = "featured stories"
Ejemplo n.º 30
0
class MeetingMinutes(AbstractReport):
    """
    Meeting minutes content type.
    """
    link_page = models.ForeignKey(
        "wagtailcore.Page",
        null=True,
        blank=False,
        on_delete=models.SET_NULL,
        related_name="+",
    )

    panels = [
        FieldPanel('date'),
        FieldPanel('summary'),
        PageChooserPanel('link_page'),
    ]

    class Meta:
        abstract = True