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

Previews don't work for unpublished pages #358

Open
thibaudcolas opened this issue Oct 30, 2023 · 1 comment
Open

Previews don't work for unpublished pages #358

thibaudcolas opened this issue Oct 30, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@thibaudcolas
Copy link
Member

https://guide.wagtail.org/admin/pages/213/view_draft/

If a page has never been published, we can’t use the live preview, nor view_draft.


Perhaps related to wagtail-localise field replacement not happening for drafts

@laymonage
Copy link
Member

This is probably because of the following code

def get_context(self, request, *args, **kwargs):
if self.live and self.show_in_menus:
context = super().get_context(request, *args, **kwargs)
pages = Page.objects.live().in_menu()
context.update(
previous=pages.filter(path__lt=self.path).last(),
next=pages.filter(path__gt=self.path).first(),
)
return context

It doesn't return the context at all if the page is not live. It should be changed to something like

def get_context(self, request, *args, **kwargs): 
    context = super().get_context(request, *args, **kwargs) 
    if self.live and self.show_in_menus: 
        pages = Page.objects.live().in_menu() 
        context.update( 
            previous=pages.filter(path__lt=self.path).last(), 
            next=pages.filter(path__gt=self.path).first(), 
        ) 
    return context 

@laymonage laymonage added the bug Something isn't working label Apr 23, 2024
@laymonage laymonage changed the title Support for drafts of unpublished pages Previews don't work for unpublished pages Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Status: 🏗 In progress
Development

No branches or pull requests

2 participants