Skip to content
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 support for previewing blog posts in list view #6245

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions cfgov/v1/jinja2/v1/blog/blog_page_list_preview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends "v1/layouts/base.html" %}

{% import 'v1/includes/organisms/post-preview.html' as preview %}

{% block content %}
<div class="wrapper content_wrapper">
<div class="content_main">
{{ preview.render( post ) }}
</div>
</div>
{% endblock %}
20 changes: 20 additions & 0 deletions cfgov/v1/models/blog_page.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from django.template.response import TemplateResponse

from wagtail import blocks
from wagtail.admin.panels import FieldPanel
from wagtail.fields import StreamField
Expand Down Expand Up @@ -40,6 +42,24 @@ def get_context(self, request, *args, **kwargs):

return context

@property
def preview_modes(self):
return super().preview_modes + [
("list_view", "List view"),
]

def serve_preview(self, request, mode_name):
if mode_name != "list_view":
return super().serve_preview(request, mode_name)

return TemplateResponse(
request,
"v1/blog/blog_page_list_preview.html",
{
"post": self,
},
)


class LegacyBlogContent(BlogContent):
content = blocks.RawHTMLBlock(
Expand Down