guide icon indicating copy to clipboard operation
guide copied to clipboard

Previews don't work for unpublished pages

Open thibaudcolas opened this issue 1 year ago • 1 comments

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

thibaudcolas avatar Oct 30 '23 12:10 thibaudcolas

This is probably because of the following code https://github.com/wagtail/guide/blob/195797c837557fd13cf91af38b8fcf4964020748/apps/core/models/content.py#L47-L55

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 avatar Apr 23 '24 06:04 laymonage