-
Notifications
You must be signed in to change notification settings - Fork 24
Add testimonials #2069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add testimonials #2069
Conversation
| def get_context(self, request, *args, **kwargs): | ||
| context = super().get_context(request, *args, **kwargs) | ||
| # Get all live testimonials that are children of this page | ||
| context["testimonials"] = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, but a more intuitive/wagtail way would be to use the tree with self.get_childre().live().type(Testimonial).order_by("-first_published_at").
| return context | ||
|
|
||
|
|
||
| class Testimonial(Page): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be named TestimonialPage by convention.
| author_url = models.URLField( | ||
| help_text="Optional URL to link the author's name to", blank=True, default="" | ||
| ) | ||
| pull_quote = StreamField( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this is done as a streamfield, rather than a markdownfield? It seems this field will only ever contain a single block.
| ), | ||
| ("md", MarkdownBlock(label="Markdown")), | ||
| ], | ||
| use_json_field=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This argument is no longer required in current versions of wagtail. Unless you want to set it to false.
| [ | ||
| ( | ||
| "rich", | ||
| RichTextBlock(features=settings.RICH_TEXT_FEATURES, label="Rich text"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are going to use the same custom settings on all richtext blocks, we could instead set the wagtail setting for it: https://docs.wagtail.org/en/stable/reference/settings.html#wagtailadmin-rich-text-editors
Uh oh!
There was an error while loading. Please reload this page.