From 8288455468ac64917b3b5e0ce39c3743fde6f8e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 28 Mar 2018 12:36:03 +0200 Subject: [PATCH] Fixed a KeyError when editing a comment. --- pillar/api/nodes/custom/comment.py | 5 ++++- pillar/web/nodes/custom/comments.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pillar/api/nodes/custom/comment.py b/pillar/api/nodes/custom/comment.py index 0795ac20..44bf9fe5 100644 --- a/pillar/api/nodes/custom/comment.py +++ b/pillar/api/nodes/custom/comment.py @@ -162,7 +162,10 @@ def edit_comment(user_id, node_id, patch): log.info('User %s edited comment %s', user_id, node_id) # Fetch the new content, so the client can show these without querying again. - node = nodes_coll.find_one(node_id, projection={'properties._content_html': 1}) + node = nodes_coll.find_one(node_id, projection={ + 'properties.content': 1, + 'properties._content_html': 1, + }) return status, node diff --git a/pillar/web/nodes/custom/comments.py b/pillar/web/nodes/custom/comments.py index 7d0993a4..b783950e 100644 --- a/pillar/web/nodes/custom/comments.py +++ b/pillar/web/nodes/custom/comments.py @@ -70,6 +70,7 @@ def comments_create(): @login_required def comment_edit(comment_id): """Allows a user to edit their comment.""" + from pillar.web import jinja api = system_util.pillar_api() @@ -80,7 +81,8 @@ def comment_edit(comment_id): return jsonify({ 'status': 'success', 'data': { - 'content_html': result.properties['_content_html'], + 'content': result.properties.content or '', + 'content_html': jinja.do_markdowned(result.properties, 'content'), }})