Compare commits
1 Commits
master
...
wip-commen
Author | SHA1 | Date | |
---|---|---|---|
d0e12401c0 |
@ -6,6 +6,7 @@ from flask import current_app
|
|||||||
import werkzeug.exceptions as wz_exceptions
|
import werkzeug.exceptions as wz_exceptions
|
||||||
|
|
||||||
from pillar.api.utils import authorization, authentication, jsonify
|
from pillar.api.utils import authorization, authentication, jsonify
|
||||||
|
from pillar.api.utils.rating import confidence
|
||||||
|
|
||||||
from . import register_patch_handler
|
from . import register_patch_handler
|
||||||
|
|
||||||
@ -25,6 +26,13 @@ def patch_comment(node_id, patch):
|
|||||||
assert patch['op'] == 'edit', 'Invalid patch operation %s' % patch['op']
|
assert patch['op'] == 'edit', 'Invalid patch operation %s' % patch['op']
|
||||||
result, node = edit_comment(user_id, node_id, patch)
|
result, node = edit_comment(user_id, node_id, patch)
|
||||||
|
|
||||||
|
# Calculate and update confidence.
|
||||||
|
rating_confidence = confidence(
|
||||||
|
node['properties']['rating_positive'], node['properties']['rating_negative'])
|
||||||
|
current_app.data.driver.db['nodes'].update_one(
|
||||||
|
{'_id': node_id},
|
||||||
|
{'$set': {'properties.confidence': rating_confidence}})
|
||||||
|
|
||||||
return jsonify({'_status': 'OK',
|
return jsonify({'_status': 'OK',
|
||||||
'result': result,
|
'result': result,
|
||||||
'properties': node['properties']
|
'properties': node['properties']
|
||||||
|
@ -179,6 +179,14 @@ class VoteCommentTest(AbstractPatchCommentTest):
|
|||||||
], patched_node['properties'].get('ratings', []))
|
], patched_node['properties'].get('ratings', []))
|
||||||
|
|
||||||
|
|
||||||
|
class CommentsSortingTest(AbstractPatchCommentTest):
|
||||||
|
def default_sorting(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def sorting_with_confidence(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class EditCommentTest(AbstractPatchCommentTest):
|
class EditCommentTest(AbstractPatchCommentTest):
|
||||||
def test_comment_edit_happy(self, token='owner-token'):
|
def test_comment_edit_happy(self, token='owner-token'):
|
||||||
pre_node = self.get(self.node_url, auth_token=token).get_json()
|
pre_node = self.get(self.node_url, auth_token=token).get_json()
|
Loading…
x
Reference in New Issue
Block a user