From 7365fb10cdf94830b212df36d2673e42801cd75d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 28 Jul 2016 10:24:01 +0200 Subject: [PATCH] patch_comment: return new ratings in response This way the client can show these without querying Pillar again. --- pillar/application/modules/nodes/custom/comment.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pillar/application/modules/nodes/custom/comment.py b/pillar/application/modules/nodes/custom/comment.py index 211bd9d3..a1009c04 100644 --- a/pillar/application/modules/nodes/custom/comment.py +++ b/pillar/application/modules/nodes/custom/comment.py @@ -92,7 +92,15 @@ def patch_comment(node_id, patch): else: result = nodes_coll.update_one({'_id': node_id}, mongo_update) - return jsonify({'_status': 'OK', 'result': result}) + # Fetch the new ratings, so the client can show these without querying again. + node = nodes_coll.find_one(node_id, + projection={'properties.rating_positive': 1, + 'properties.rating_negative': 1}) + + return jsonify({'_status': 'OK', + 'result': result, + 'properties': node['properties'] + }) def assert_is_valid_patch(node_id, patch):