class PostPage(Page): body = RichTextField(blank=True) categories = ParentalManyToManyField('blog.BlogCategory', blank=True) tags = ClusterTaggableManager(through='blog.BlogPageTag', blank=True) content_panels = Page.content_panels + [ FieldPanel('body', classname="full"), FieldPanel('categories', widget=forms.CheckboxSelectMultiple), FieldPanel('tags'), ]
class EventPage(Page): date_from = models.DateField("Start date", null=True) date_to = models.DateField( "End date", null=True, blank=True, help_text="Not required if event is on a single day", ) time_from = models.TimeField("Start time", null=True, blank=True) time_to = models.TimeField("End time", null=True, blank=True) audience = models.CharField(max_length=255, choices=EVENT_AUDIENCE_CHOICES) location = models.CharField(max_length=255) body = RichTextField(blank=True) cost = models.CharField(max_length=255) signup_link = models.URLField(blank=True) feed_image = models.ForeignKey( "wagtailimages.Image", null=True, blank=True, on_delete=models.SET_NULL, related_name="+", ) categories = ParentalManyToManyField(EventCategory, blank=True) search_fields = [ index.SearchField("get_audience_display"), index.SearchField("location"), index.SearchField("body"), index.FilterField("url_path"), ] password_required_template = "tests/event_page_password_required.html" base_form_class = EventPageForm content_panels = [ FieldPanel("title", classname="full title"), FieldPanel("date_from"), FieldPanel("date_to"), FieldPanel("time_from"), FieldPanel("time_to"), FieldPanel("location"), FieldPanel("audience"), FieldPanel("cost"), FieldPanel("signup_link"), InlinePanel("carousel_items", label="Carousel items"), FieldPanel("body", classname="full"), InlinePanel("speakers", label="Speakers", heading="Speaker lineup"), InlinePanel("related_links", label="Related links"), FieldPanel("categories"), # InlinePanel related model uses `pk` not `id` InlinePanel("head_counts", label="Head Counts"), ] promote_panels = [ MultiFieldPanel(COMMON_PANELS, "Common page configuration"), FieldPanel("feed_image"), ]
class PostPage(Page): header_image = models.ForeignKey( "wagtailimages.Image", null=True, blank=True, on_delete=models.SET_NULL, related_name="+", ) overview = models.CharField( max_length=250, blank=True, ) body = RichTextField(blank=True) # carousel_image = models.ForeignKey( # "wagtailimages.Image", # null=True, # blank=False, # on_delete=models.SET_NULL, # related_name="+", # ) categories = ParentalManyToManyField('porto.PortoCategory', blank=True) link_url = models.URLField( max_length=250, blank=True, ) tags = ClusterTaggableManager(through='porto.PortoPageTag', blank=True) date = models.DateField("Post date") content_panels = Page.content_panels + [ ImageChooserPanel("header_image"), FieldPanel('overview'), FieldPanel('body', classname="full"), FieldPanel('link_url'), FieldPanel('categories', widget=forms.CheckboxSelectMultiple), FieldPanel('tags'), FieldPanel('date'), # MultiFieldPanel( # [InlinePanel("carousel_image", max_num=5, # min_num=1, label="Image")], # heading="Carousel Images", # ), ] search_fields = Page.search_fields + [ index.SearchField('title'), index.SearchField('body'), ] @property def blog_page(self): return self.get_parent().specific def get_context(self, request, *args, **kwargs): context = super(PostPage, self).get_context(request, *args, **kwargs) context['blog_page'] = self.blog_page context['post'] = self return context
class BlogPage(FoundationMetadataPageMixin, Page): body = StreamField(base_fields) category = ParentalManyToManyField( BlogPageCategory, help_text='Which blog categories is this blog page associated with?', blank=True, verbose_name="Categories", ) tags = ClusterTaggableManager(through=BlogPageTag, blank=True) zen_nav = True feature_comments = models.BooleanField( default=False, help_text='Check this box to add a comment section for this blog post.', ) content_panels = Page.content_panels + [ MultiFieldPanel([InlinePanel("authors", label="Author", min_num=1)], heading="Author(s)"), FieldPanel('category'), StreamFieldPanel('body'), FieldPanel('feature_comments'), ] promote_panels = FoundationMetadataPageMixin.promote_panels + [ FieldPanel('tags'), ] settings_panels = [ PublishingPanel(), FieldPanel('first_published_at'), PrivacyModalPanel(), ] subpage_types = [] def get_context(self, request): context = super().get_context(request) context['related_posts'] = get_content_related_by_tag(self) context[ 'show_comments'] = settings.USE_COMMENTO and self.feature_comments # Pull this object specifically using the English page title blog_page = BlogIndexPage.objects.get(title_en__iexact='Blog') # If that doesn't yield the blog page, pull using the universal title if blog_page is None: blog_page = BlogIndexPage.objects.get(title__iexact='Blog') if blog_page: context['blog_index'] = blog_page return set_main_site_nav_information(self, context, 'Homepage')
class BlogPage(Page): sub_title = models.CharField(max_length=255, blank=True) publication_date = models.DateField("Post date") colour = ColorField(default='#bbcee5') language = ParentalManyToManyField('blog.BlogPageLanguage') intro = RichTextField(blank=True) body = RichTextField(blank=True) tags = ClusterTaggableManager(through=BlogPageTag, blank=True) categories = ParentalManyToManyField('blog.BlogCategory', blank=True) cover_image = models.ForeignKey( CustomImage, null=True, # blank=True, on_delete=models.SET_NULL, related_name='+' ) def main_image(self): gallery_item = self.gallery_images.first() if gallery_item: return gallery_item.image else: return None search_fields = Page.search_fields + [ index.SearchField('intro'), index.SearchField('body'), ] content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel('sub_title'), FieldPanel('publication_date'), ImageChooserPanel('cover_image'), FieldPanel('language'), FieldPanel('colour'), FieldPanel('tags'), FieldPanel('categories', widget=forms.CheckboxSelectMultiple), ], heading="Blog information"), FieldPanel('intro'), FieldPanel('body'), InlinePanel('gallery_images', label="Gallery images"), ]
class InsightsPage(Page): date = models.DateField("Post date") intro = models.CharField(max_length=250) body = StreamField([ ('heading', blocks.CharBlock(form_classname="full title")), ('paragraph', blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('raw_HTML', RawHTMLBlock()), ('block_quote', BlockQuoteBlock()), ('embed', EmbedBlock()), ]) tags = ClusterTaggableManager(through=InsightsPageTag, blank=True) categories = ParentalManyToManyField('insights.InsightsCategory', blank=True) authors = ParentalManyToManyField('insights.InsightsAuthor', blank=True) def main_image(self): gallery_item = self.gallery_images.first() if gallery_item: return gallery_item.image else: return None search_fields = Page.search_fields + [ index.SearchField('intro'), index.SearchField('body'), ] content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel('date'), FieldPanel('tags'), FieldPanel('categories', widget=forms.CheckboxSelectMultiple), ], heading="Blog information"), MultiFieldPanel([ InlinePanel( 'insights_authors', label="Author", min_num=1, max_num=4) ], heading="Authors"), FieldPanel('intro'), StreamFieldPanel('body'), InlinePanel('gallery_images', label="Gallery images"), ]
class StaffListing(BasePage): subpage_types = ["Employee"] max_count_per_parent = 1 heading = models.CharField("Überschrift", max_length=50, default="Mitarbeiter*innen") intro = RichTextField("Intro", blank=True) image = models.ForeignKey( Image, on_delete=models.SET_NULL, null=True, blank=True, related_name="+", verbose_name="Bild", ) outro = RichTextField("Outro", blank=True) departments = ParentalManyToManyField( Department, blank=True, related_name="+", verbose_name="Anzuzeigende Abteilungen", help_text= "Es werden nur Mitarbeiter:innen aus diesen Abteilungen angezeigt", ) content_panels = [ FieldPanel("title"), FieldPanel("heading"), FieldPanel("intro"), ImageChooserPanel("image"), HelpPanel( "An dieser Stelle kommen die Mitarbeiter*innen, die als Unterseiten angelegt sind.", heading="Mitarbeiter*innen", ), FieldPanel("departments", widget=forms.CheckboxSelectMultiple), FieldPanel("outro"), ] class Meta: verbose_name = "Auflistung von Mitarbeiter*innen" verbose_name_plural = "Auflistungen von Mitarbeiter*innen" def get_context(self, request): context = super().get_context(request) context["people"] = [] for department in self.departments.all(): people = Employee.objects.filter( departments=department).order_by("title") if people: context["people"].append({ "department": department, "people": people }) return context
class BlogPage(RoutablePageMixin, Page): subpage_types = [] parent_page_types = ['blogger.BlogIndexPage'] date = models.DateField("Post date") intro = models.CharField(max_length=250) body = RichTextField(blank=True) tags = ClusterTaggableManager(through=BlogPageTag, blank=True) categories = ParentalManyToManyField('blogger.BlogCategory', blank=True) release = models.IntegerField(default=2000) sequel = StreamField([ ('title_and_text', blocks.TitleAndTextBlock()), ], null=True, blank=True ) @route(r'^search/$', name="post_search") def post_search(self, request, *args, **kwargs): search_query = request.GET.get('q', None) self.posts = self.get_posts() if search_query: self.posts = self.posts.filter(body__contains=search_query) self.search_term = search_query self.search_type = 'search' return Page.serve(self, request, *args, **kwargs) def main_image(self): gallery_item = self.gallery_images.first() if gallery_item: return gallery_item.image else: return None search_fields = Page.search_fields + [ index.SearchField('intro'), index.SearchField('body'), ] content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel('date'), FieldPanel('release'), FieldPanel('tags'), FieldPanel("categories", widget=forms.CheckboxSelectMultiple), InlinePanel('customcomments', label='Comments'), ], heading='Blog information'), FieldPanel('intro'), FieldPanel('body', classname='full'), InlinePanel('gallery_images', label='Gallery Images'), StreamFieldPanel("sequel"), ] def get_absolute_url(self): return self.get_url()
class BreadPage(Page): """ Detail view for a specific bread """ 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) origin = models.ForeignKey( Country, on_delete=models.SET_NULL, null=True, blank=True, ) # We include related_name='+' to avoid name collisions on relationships. # e.g. there are two FooPage models in two different apps, # and they both have a FK to bread_type, they'll both try to create a # relationship called `foopage_objects` that will throw a valueError on # collision. bread_type = models.ForeignKey('breads.BreadType', null=True, blank=True, on_delete=models.SET_NULL, related_name='+') ingredients = ParentalManyToManyField('BreadIngredient', blank=True) content_panels = Page.content_panels + [ FieldPanel('introduction', classname="full"), ImageChooserPanel('image'), StreamFieldPanel('body'), FieldPanel('origin'), FieldPanel('bread_type'), InlinePanel('documents', label="Documents"), MultiFieldPanel([ FieldPanel( 'ingredients', widget=forms.CheckboxSelectMultiple, ), ], heading="Additional Metadata", classname="collapsible collapsed"), ] search_fields = Page.search_fields + [ index.SearchField('body'), ] parent_page_types = ['BreadsIndexPage']
class BlogDetailPage(Page): """ Parental blog Detail page """ subpage_types = [] parent_page_types = ['blog.BlogListingPage'] tags = ClusterTaggableManager(through=BlogPageTag, blank=True) custom_title = models.CharField( max_length=100, blank=False, null=False, help_text='Add your title', ) banner_image = models.ForeignKey( 'wagtailimages.Image', blank=False, null=True, related_name='+', on_delete=models.SET_NULL, ) categories = ParentalManyToManyField('blog.BlogCategory', blank=True) content = StreamField([ ('title_and_text', blocks.TitleAndTextBlock()), ('full_richtext', blocks.RichTextBlock()), ('cards', blocks.CardBlock()), ('cta', blocks.CTABlock()), ], null=True, blank=True) content_panels = Page.content_panels + [ FieldPanel('custom_title'), FieldPanel("tags"), ImageChooserPanel('banner_image'), StreamFieldPanel('content'), MultiFieldPanel([ InlinePanel('blog_authors', label='Author', min_num=1, max_num=4) ], heading='Authors'), MultiFieldPanel( [FieldPanel('categories', widget=forms.CheckboxSelectMultiple)], heading='Categories'), ] api_fields = [ APIField('blog_authors'), APIField('content'), ] def save(self, *args, **kwargs): key = make_template_fragment_key('blog_post_preview', [self.id]) cache.delete(key) return super().save(*args, **kwargs)
class ArticlesPage(Page): date = models.DateField("Post date") created_at = models.DateTimeField(auto_now_add=True, blank=True) published_at = models.DateTimeField(auto_now_add=False, blank=True, null=True, help_text=u"Needs to be converted to PST plz and ty") tags = ClusterTaggableManager(through=ArticlePageTag, blank=True) authors = ParentalManyToManyField('articles.ArticleAuthor', blank=True) categories = ParentalManyToManyField('articles.ArticleCategory', blank=True) cover_image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+' ) intro = models.CharField(max_length=250) body = StreamField([ ('heading', blocks.CharBlock(classname="full title")), ('image', ImageChooserBlock()), ('blockquote', BlockQuoteBlock()), ('paragraph', blocks.RichTextBlock()), ('embed', EmbedBlock()), ]) content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel('authors', widget=forms.SelectMultiple), FieldPanel('date'), FieldPanel('tags'), FieldPanel('categories', widget=forms.SelectMultiple), ], heading="Article information"), ImageChooserPanel('cover_image'), FieldPanel('intro'), StreamFieldPanel('body'), FieldPanel('published_at'), ] def articles(self): articles = ArticlesPage.objects.sibling_of(self,inclusive=False).order_by('-first_published_at') return articles def related(self): return ArticlesPage.objects.sibling_of(self,inclusive=False).filter(tags__in=self.tags.all()).order_by('-first_published_at').distinct()
class Place(index.Indexed, ClusterableModel): name = models.CharField(max_length=255, null=False, blank=False, unique=True) details = models.TextField(null=False, blank=False, help_text="Add place details") duration_of_visit = models.DurationField( null=True, blank=True, default='00:00:00', verbose_name=('Duration Of Visit (HH:MM:SS)'), help_text=('[DD] [HH:[MM:]]ss[.uuuuuu] format')) map_icon = models.ForeignKey("wagtailimages.Image", null=True, blank=True, on_delete=models.SET_NULL, related_name="+") trip_types = ParentalManyToManyField('TripType', blank=False) location_tags = ParentalManyToManyField('LocationTag', blank=False) panels = [ FieldPanel("name"), FieldPanel("details"), FieldPanel("duration_of_visit"), ImageChooserPanel("map_icon"), MultiFieldPanel([ InlinePanel("place_images", min_num=1), ], heading="Images"), FieldPanel('trip_types', widget=forms.CheckboxSelectMultiple), FieldPanel('location_tags', widget=forms.CheckboxSelectMultiple), ] search_fields = [ index.SearchField('name', partial_match=True), ] def __str__(self): return self.name
class BlogDetailPage(Page): template = "blog/blog_detail.html" subpage_types =[] parent_page_types = ['blog.BlogListingPage'] custom_title = models.CharField( max_length = 100, blank = True, null = True, help_text = 'Overwrites the default title' ) blog_image = models.ForeignKey( "wagtailimages.Image", blank = False, null = True, related_name ='+', on_delete = models.SET_NULL, ) categories = ParentalManyToManyField("blog.BlogCategory") content = StreamField( [ ("title_and_text",blocks.TitleAndTextBlock()), ("full_richtext",blocks.RichTextBlock()), ("cards",blocks.CardBLock()), ("cta",blocks.CTABlock()), ], null =True, blank=True, ) content_panels = Page.content_panels + [ FieldPanel("custom_title"), ImageChooserPanel("blog_image"), MultiFieldPanel( [ InlinePanel("blog_authors",label="Author",min_num=1,max_num=4) ],heading="Author(s)" ), MultiFieldPanel( [ FieldPanel("categories",widget= forms.CheckboxSelectMultiple) ],heading="Categories" ), StreamFieldPanel("content"), ] api_fields =[ APIField("blog_authors"), APIField("content"), ]
class BlogPage(Page): date = models.DateField("Post date") intro = models.CharField(max_length=250) # set default for previous pages author = models.CharField(max_length=250, default="sandeep", blank=False) body = RichTextField(blank=True) stream_body = StreamField([ ('heading', blocks.CharBlock(classname="full title")), ('paragraph', blocks.RichTextBlock()), ('image', ImageChooserBlock()), ], blank=True, null=True) tags = ClusterTaggableManager(through=BlogPageTag, blank=True) categories = ParentalManyToManyField("wagtail_blog.BlogCategory", blank=True) def main_image(self): gallery_item = self.gallery_images.first() if gallery_item: return gallery_item.image else: return None search_fields = Page.search_fields + [ index.SearchField("intro"), index.SearchField("body"), index.SearchField("author") # index.FilterField("tags"), ] api_fields = [ APIField("date"), APIField("intro"), APIField("author"), APIField("body"), APIField("stream_body"), APIField("tags"), ] content_panels = Page.content_panels + [ MultiFieldPanel( [ FieldPanel("date"), FieldPanel("tags"), FieldPanel("categories", widget=forms.CheckboxSelectMultiple), ], heading="Blog information", ), FieldPanel("date"), FieldPanel("intro"), FieldPanel("author"), FieldPanel("body", classname="full"), StreamFieldPanel("stream_body"), InlinePanel("gallery_images", label="Gallery images"), ]
class PostPage(Page): body = MarkdownField() date = models.DateTimeField(verbose_name="Post date", default=datetime.today) body_stream = StreamField( [('heading', blocks.CharBlock(classname='full title')), ('paragraph', blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('code', CodeBlock())], blank=True) excerpt = MarkdownField( verbose_name='excerpt', blank=True, ) header_image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+', ) categories = ParentalManyToManyField('blog.BlogCategory', blank=True) tags = ClusterTaggableManager(through='blog.BlogPageTag', blank=True) content_panels = Page.content_panels + [ ImageChooserPanel('header_image'), MarkdownPanel("body"), MarkdownPanel("excerpt"), StreamFieldPanel("body_stream"), FieldPanel('categories', widget=forms.CheckboxSelectMultiple), FieldPanel('tags'), ] settings_panels = Page.settings_panels + [ FieldPanel('date'), ] @property def blog_page(self): return self.get_parent().specific ''' @property def category_page(self): return self.get_parent().specific ''' def get_context(self, request, *args, **kwargs): context = super(PostPage, self).get_context(request, *args, **kwargs) context['blog_page'] = self.blog_page #context['category_page'] = self.category_page context['post'] = self return context
class BlogPage(RoutablePageMixin,Page): date = models.DateField("Post date") intro = models.CharField(max_length=250) template = 'blogs/blog_page.html' ajax_template = "blogs/blog_page_ajax.html" # body = RichTextField(features=['h1','h2', 'h3','h4','h5','h6', 'bold', 'italic', 'link','ol','ul','hr','document-link','image','embed','code','superscript','subscript','blockquote']) body = StreamField([ ('heading', blocks.CharBlock(classname="full title")), ('paragraph', blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('list', blocks.ListBlock(blocks.CharBlock(label=""))), ('document', blocks.BlockQuoteBlock()), ]) tags = ClusterTaggableManager(through=BlogPageTag, blank=True) author = models.CharField(max_length=255,default='Adrian') categories = ParentalManyToManyField('BlogCategory', blank=True) def main_image(self): gallery_item = self.gallery_images.first() if gallery_item: return gallery_item.image else: return None search_fields = Page.search_fields + [ index.SearchField('intro'), index.SearchField('body'), ] content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel('date'), FieldPanel('tags'), ], heading="Blog information"), FieldPanel('intro'), FieldPanel('author'), # FieldPanel('body'), StreamFieldPanel('body'), InlinePanel('gallery_images', label="Gallery images"), FieldPanel('categories', widget=forms.CheckboxSelectMultiple), ] def get_context(self, request): context = super().get_context(request) raw_url = context['request'].get_raw_uri() parse_result = six.moves.urllib.parse.urlparse(raw_url) lista = parse_result.path.split('/') slug = lista[4] print(slug) comment1 = Comment.objects.filter(post__slug = slug) # comment2 = Comment.objects.filter(post__slug = 'post-1') # print(comment) post = BlogPage.objects.all() context['comments'] = comment1 return context
class OwriIndexPage(StrandChildMixin, Page, WithStreamField): search_fields = Page.search_fields + [ index.SearchField('body'), ] strands = ParentalManyToManyField('cms.StrandPage', blank=True) subpage_types = ['OwriIndexPage', 'OwriRichTextPage'] def get_context(self, request, *args, **kwargs): context = super(OwriIndexPage, self).get_context(request) context = self.add_parent_strand_content_to_context(context) return context
class ApplicationBase(EmailForm, WorkflowStreamForm): # type: ignore is_createable = False # Adds validation around forms & workflows. Isn't on Workflow class due to not displaying workflow field on Round base_form_class = WorkflowFormAdminForm reviewers = ParentalManyToManyField( settings.AUTH_USER_MODEL, related_name='%(class)s_reviewers', limit_choices_to=LIMIT_TO_REVIEWERS, blank=True, ) objects = PageManager.from_queryset(ApplicationBaseManager)() parent_page_types = ['apply_home.ApplyHomePage'] def get_template(self, request, *args, **kwargs): # We want to force children to use our base template # template attribute is ignored by children return 'funds/application_base.html' def detail(self): # The location to find out more information return self.application_public.first() @cached_property def open_round(self): return RoundBase.objects.child_of(self).open().first() def next_deadline(self): try: return self.open_round.end_date except AttributeError: # There isn't an open round return None def serve(self, request): if hasattr(request, 'is_preview') or not self.open_round: return super().serve(request) # delegate to the open_round to use the latest form instances request.show_round = True return self.open_round.serve(request) content_panels = WorkflowStreamForm.content_panels + [ FieldPanel('reviewers'), ] edit_handler = TabbedInterface([ ObjectList(content_panels, heading='Content'), EmailForm.email_tab, ObjectList(WorkflowStreamForm.promote_panels, heading='Promote'), ])
class BlogDetailPage(Page): """Parental Blog detail Page""" template = 'blog/blog_detail_page.html' subpage_type = [] # limit the page which can be the parent of this page parent_page_types = ["blog.BlogListingPage"] tags = ClusterTaggableManager(through="BlogPageTags", blank=True) custom_title = models.CharField( max_length=100, blank=False, null=False, help_text="Overwrites the default title", ) banner_image = models.ForeignKey( "wagtailimages.Image", blank=False, null=True, related_name="+", on_delete=models.SET_NULL, ) categories = ParentalManyToManyField('blog.BlogCategory', blank=True) content = StreamField( [ ("Full_richtext", Blocks.RichtextBLock()), ("simple_richtext", Blocks.SimpleRichtextBLock()), ("card", Blocks.CardBlock()), ("cta", Blocks.CTABlock()), ], null=True, blank=True, ) content_panels = Page.content_panels + [ FieldPanel('custom_title'), FieldPanel('tags'), ImageChooserPanel('banner_image'), StreamFieldPanel('content'), MultiFieldPanel([ InlinePanel("blog_authors", label='Author', min_num=1, max_num=3) ], heading="Author(s)"), MultiFieldPanel( [FieldPanel("categories", widget=forms.CheckboxSelectMultiple)], heading="Categories") ] # to add the field to the api content url= http://127.0.0.1:8000/api/v2/pages/16/ api_fields = [APIField("blog_authors")] def save(self, *args, **kwargs): key = make_template_fragment_key("blog_post_preview", [self.id]) cache.delete(key) return super().save(*args, **kwargs)
class SponsoredPage(Page): advert = models.ForeignKey(Advert, blank=True, null=True, on_delete=models.SET_NULL) author = models.ForeignKey(Author, blank=True, null=True, on_delete=models.SET_NULL) intro = models.TextField() categories = ParentalManyToManyField(Category)
class StoryIndexPage(Page, Orderable): STORIES_PER_PAGE = 6 """The 'media' section of the site will host multiple StoryIndex pages Each one is configured to show certain kinds of stories and other optional sections we will define.""" subpage_types = [ 'news.StoryPage' ] intro = RichTextField(blank=True) # determines what type of stories are displayed on this page categories = ParentalManyToManyField('news.StoryCategory', blank=True) content_panels = Page.content_panels + [ FieldPanel('intro', classname="full"), FieldPanel('categories', widget=forms.CheckboxSelectMultiple) ] def get_context(self, request): context = super().get_context(request) stories = StoryPage.objects.live() #child_of(self).live() stories = stories.order_by('-date') author = request.GET.get('author', '') if author: # A bit wonky, but if using author filter we serve all content types, # not just the categories under this listing. if author == ANONYMOUS_AUTHOR_NAME: stories = stories.filter(author=None) else: stories = stories.filter(author__username=author) else: stories = stories.filter(categories__in=list(self.categories.all())).distinct() tag = request.GET.get('tag', '') if tag: stories = stories.filter(tags__name=tag) # Pagination. paginator = Paginator(stories, self.STORIES_PER_PAGE) page = request.GET.get("page") try: stories = paginator.page(page) except: stories = paginator.page(1) featured = FeaturedStory.objects.all().order_by('-story__date') context['stories'] = stories context['featured'] = featured context['peer_pages'] = self.get_siblings() return context
class PiecePageAbstract(Page): body = RichTextField(verbose_name=_('body'), blank=True) tags = ClusterTaggableManager(through='PiecePageTag', blank=True) date = models.DateField( _("Post date"), default=datetime.datetime.today, help_text=_("This date may be displayed on the Piece post. It is not " "used to schedule posts to go live at a later date.")) header_image = models.ForeignKey(get_image_model_string(), null=True, blank=True, on_delete=models.SET_NULL, related_name='+', verbose_name=_('Header image')) search_fields = Page.search_fields + [ index.SearchField('body'), ] Piece_categories = ParentalManyToManyField( 'PieceCategory', through='PieceCategoryPiecePage', blank=True) settings_panels = [ MultiFieldPanel([ FieldRowPanel([ FieldPanel('go_live_at'), FieldPanel('expire_at'), ], classname="label-above"), ], 'Scheduled publishing', classname="publishing"), FieldPanel('date'), ] def get_absolute_url(self): return self.url class Meta: abstract = True verbose_name = _('Piece page') verbose_name_plural = _('Piece pages') api_fields = [APIField('body')] content_panels = [ FieldPanel('title', classname="full title"), MultiFieldPanel([ FieldPanel('tags'), FieldPanel('Piece_categories'), ], heading="Tags and Categories"), ImageChooserPanel('header_image'), FieldPanel('body', classname="full"), ]
class PostPage(Page): body = RichTextField() date = models.DateTimeField(verbose_name="Post date", default=datetime.datetime.today) excerpt = MarkdownField( verbose_name='excerpt', blank=True, ) header_image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+', ) categories = ParentalManyToManyField('blog.BlogCategory', blank=True) tags = ClusterTaggableManager(through='blog.BlogPageTag', blank=True) content_panels = Page.content_panels + [ ImageChooserPanel('header_image'), MarkdownPanel("body"), MarkdownPanel("excerpt"), FieldPanel('categories', widget=forms.CheckboxSelectMultiple), FieldPanel('tags'), ] settings_panels = Page.settings_panels + [ FieldPanel('date'), ] search_fields = Page.search_fields + [ # Inherit search_fields from Page index.SearchField('body'), ] @property def blog_page(self): return self.get_parent().specific def get_context(self, request, *args, **kwargs): context = super(PostPage, self).get_context(request, *args, **kwargs) context['blog_page'] = self.blog_page context['post'] = self if request.user: if not request.user.is_staff and not request.user.is_superuser: try: self.page_views = self.page_views + 1 except AttributeError: self.page_views = 1 self.save() return context def get_absolute_url(self): return self.url
class HowToPage(Page): categories = ParentalManyToManyField('categories.Category') abstract = models.TextField() content = RichTextField() parent_page_types = ['howto.HowToIndexPage'] content_panels = Page.content_panels + [ FieldPanel('categories', widget=CheckboxSelectMultiple), FieldPanel('abstract', classname="full"), FieldPanel('content', classname="full"), ]
class InternationalTopicLandingPage(panels.InternationalTopicLandingPagePanels, BaseInternationalPage): parent_page_types = [ 'great_international.InternationalHomePage', 'great_international.InvestmentAtlasLandingPage', 'great_international.WhyInvestInTheUKPage', ] subpage_types = [ 'great_international.InternationalArticleListingPage', 'great_international.InternationalCampaignPage', 'great_international.InternationalInvestmentSectorPage', # NEW Atlas sector page ] landing_page_title = models.CharField(max_length=255) hero_image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+' ) hero_teaser = models.CharField(max_length=255, null=True, blank=True) tags = ParentalManyToManyField(snippets.Tag, blank=True) hero_video = models.ForeignKey( 'wagtailmedia.Media', null=True, blank=True, on_delete=models.SET_NULL, related_name='+', ) related_page_one = models.ForeignKey( 'wagtailcore.Page', null=True, blank=True, on_delete=models.SET_NULL, related_name='+' ) related_page_two = models.ForeignKey( 'wagtailcore.Page', null=True, blank=True, on_delete=models.SET_NULL, related_name='+' ) related_page_three = models.ForeignKey( 'wagtailcore.Page', null=True, blank=True, on_delete=models.SET_NULL, related_name='+' )
class MyblogDetailPage(Page): """Blog detail page""" template = "myblog/myblog_detail_page.html" custom_title = models.CharField( max_length=100, blank=False, null=False, help_text="Overwrites default title" ) blog_image = models.ForeignKey( "wagtailimages.Image", blank=False, null=True, on_delete=models.SET_NULL, related_name="+" ) categories = ParentalManyToManyField("myblog.MyBlogCategory", blank=True) content = StreamField( [ ("title_and_text", blocks.TitleAndTextBlock()), ("rich_text", blocks.RichTextBlock()), ("simple_text", blocks.SimpleTextBlock()), ("cards", blocks.CardBlock()), ("cta", blocks.CTABlock()) ], null=True, blank=True ) content_panels = Page.content_panels + [ FieldPanel("custom_title"), ImageChooserPanel("blog_image"), MultiFieldPanel( [ InlinePanel("blog_authors", label="Author", min_num=1, max_num=5) ], heading="Author(s)" ), MultiFieldPanel( [ FieldPanel("categories", widget=forms.CheckboxSelectMultiple), ], heading="categories" ), StreamFieldPanel("content"), ]
class PostPage(Page): summary = RichTextField(blank=True) image_big = models.ForeignKey('wagtailimages.Image', on_delete=models.PROTECT, related_name='+', blank=True, null=True) body = StreamField([ ('paragraph', blocks.RichTextBlock()), ('image', ImageChooserBlock(icon="image")), ('embedded_video', EmbedBlock(icon="media")), ('link_enhanced', LinkEnhanced()), ('doc_enhanced', DocumentEnhanced()), ('form_to_out', FormToOutput()), ]) date = models.DateTimeField(verbose_name="Post date", default=datetime.datetime.today) categories = ParentalManyToManyField('blog.BlogCategory', blank=True) tags = ClusterTaggableManager(through='blog.BlogPageTag', blank=True) #author = SnippetChooserBlock('blog.Authors', blank=True) author = models.ForeignKey('blog.Authors', on_delete=models.PROTECT, related_name='+', blank=True, null=True) content_panels = Page.content_panels + [ ImageChooserPanel('image_big', classname="full"), FieldPanel('summary'), StreamFieldPanel('body'), FieldPanel('categories', widget=forms.CheckboxSelectMultiple), FieldPanel('tags'), ] settings_panels = Page.settings_panels + [ FieldPanel('date'), SnippetChooserPanel('author'), ] def get_posts(self): return PostPage.objects.live().order_by('-date')[:6] @property def blog_page(self): return self.get_parent().specific def get_context(self, request, *args, **kwargs): context = super(PostPage, self).get_context(request, *args, **kwargs) context['blog_page'] = self.blog_page context['post'] = self context['posts'] = self.get_posts() return context
class BlogPage(Page): teasertext = models.TextField(blank=True, null=True, verbose_name="Blog Teaser Text") author = models.CharField(max_length=255, blank=True, verbose_name="Author Name") create_date = models.DateTimeField(auto_now_add=True) update_date = models.DateTimeField(auto_now=True) body = RichTextField(blank=True, verbose_name="Blog Text") categories = ParentalManyToManyField('cms_snippets.Category', blank=True) image = models.ForeignKey( 'cms_images.CustomImage', null=True, blank=True, on_delete=models.SET_NULL, related_name='+', verbose_name="Blog Image", help_text="The Image that is shown on the blog page " + "and the blog index page") subpage_types = [] content_panels = [ MultiFieldPanel([ FieldPanel('title'), FieldPanel('teasertext'), FieldPanel('author'), FieldPanel('body', classname="full"), FieldPanel('categories', widget=forms.CheckboxSelectMultiple), ImageChooserPanel('image') ]), ] promote_panels = [ MultiFieldPanel([ FieldPanel('slug'), FieldPanel('seo_title'), FieldPanel('search_description') ]) ] edit_handler = TabbedInterface([ ObjectList(content_panels, heading='Content'), ObjectList(promote_panels, heading='Promote') ]) @property def creator(self): return self.owner
class LoguePage(Page): date = models.DateField("Post date") header_image = models.ForeignKey( "wagtailimages.Image", null=True, blank=True, on_delete=models.SET_NULL, related_name="+" ) intro = models.CharField(max_length=250) body = StreamField( [ ("heading", blocks.CharBlock(classname="full title")), ("paragraph", blocks.RichTextBlock()), ("block_quote", blocks.BlockQuoteBlock()), ("image", ImageChooserBlock()), ], null=True, ) tags = ClusterTaggableManager(through=LoguePageTag, blank=True) categories = ParentalManyToManyField("logue.LogueCategory", blank=True) feed_image = models.ForeignKey( "wagtailimages.Image", null=True, blank=True, on_delete=models.SET_NULL, related_name="+" ) def main_image(self): gallery_item = self.gallery_images.first() if gallery_item: return gallery_item.image else: return None search_fields = Page.search_fields + [ index.SearchField("intro"), index.SearchField("body"), index.FilterField("date"), ] content_panels = Page.content_panels + [ MultiFieldPanel( [ InlinePanel("logue_authors", label="Author", min_num=1, max_num=6), FieldPanel("date"), FieldPanel("tags"), FieldPanel("categories", widget=forms.CheckboxSelectMultiple), ], heading="Logue information", ), ImageChooserPanel("header_image"), FieldPanel("intro"), StreamFieldPanel("body"), InlinePanel("gallery_images", label="Gallery images"), InlinePanel("related_links", label="Related links"), ] promote_panels = [ImageChooserPanel("feed_image")]
class BlogPost(Page): cover_image = models.ForeignKey('wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+') text = models.TextField() index_text = models.CharField(max_length=255) authors = ParentalManyToManyField(Teammate) categories = ParentalManyToManyField(Category) date = models.DateField("Post date") content_panels = Page.content_panels + [ ImageChooserPanel('cover_image'), FieldPanel('text'), FieldPanel('index_text'), FieldPanel('date'), FieldPanel('categories'), FieldPanel('authors') ] parent_page_types = ['website.BlogPostsPage']