fsr-de / myHPI

Django/Wagtail page serving myhpi.de
https://myhpi.de
11 stars 11 forks source link

Missing templates for first and second level menu items may cause internal server errors #460

Closed lukasrad02 closed 7 months ago

lukasrad02 commented 8 months ago

Some page types do not have an HTML template, for example first and second level menu items. When accessing these pages by their path, one will be redirected to a subpage that can be rendered (see also #394). However, the page preview in the Wagtail admin interface does not follow the redirect and thus fails.

Steps to reproduce

  1. Create a new first or second level menu item page
  2. Fill out all required fields (page title, slug, …) so that there a no validation errors
  3. Open the live preview of the wagtail editor

Expected behavior

There is no live preview for pages without a template or the error is caught and a user-friendly notice is shown.

Actual behavior

A TemplateDoesNotExist exception is thrown and not caught. This causes an unspecific internal server error message (or the exact stack trace in debug mode) to be displayed.

Additional context

Wagtail remembers whether a user used the live preview panel when editing a page last time and reopens it when visiting the editor for any page. Therefore, this error does not only occur when manually opening the live preview for a menu item (why should anyone do this), but also when the current user used the live preview on a information/minutes page before.

I don't know whether this some issue in our code or a problem of Wagtail itself. The Wagtail repo does not seem to have an issue for this yet.