~homeworkprod/byceps

37a7d8f376f37060c83fa6304e48e04fd300db16 — Jochen Kupperschmidt 1 year, 8 months ago e7affb6
Handle errors on news item body rendering in public views
2 files changed, 10 insertions(+), 1 deletions(-)

M byceps/blueprints/news/templates/news/_item.html
M byceps/blueprints/news/views.py
M byceps/blueprints/news/templates/news/_item.html => byceps/blueprints/news/templates/news/_item.html +5 -0
@@ 11,6 11,11 @@
    {%- endif %}
  </footer>
  <div class="body">
{% if item.body is not none %}
{{ item.body|safe }}
{%- else %}
  {% from 'macros/misc.html' import render_notification %}
  {{ render_notification('Bei der Anzeige der News ist ein Fehler aufgetreten.', category='danger', icon='warning') }}
{%- endif %}
  </div>
</article>

M byceps/blueprints/news/views.py => byceps/blueprints/news/views.py +5 -1
@@ 100,5 100,9 @@ def _may_view_drafts(user):


def _replace_body_with_rendered_body(item):
    rendered_body = news_service.render_body(item.body)
    try:
        rendered_body = news_service.render_body(item.body)
    except Exception as e:
        rendered_body = None  # Not the best error indicator.

    return dataclasses.replace(item, body=rendered_body)