Vue Comments: Comments ported to Vue + DnD fileupload

* Drag and drop files to comment editor to add a file attachment
* Using Vue to render comments

Since comments now has attachments we need to update the schemas
./manage.py maintenance replace_pillar_node_type_schemas
This commit is contained in:
2018-12-12 11:45:47 +01:00
parent bba1448acd
commit fbcce7a6d8
45 changed files with 2248 additions and 1477 deletions

View File

@@ -35,12 +35,11 @@ class CommentTest(AbstractPillarTest):
def test_write_comment(self):
with self.login_as(self.user_uid):
comment_url = flask.url_for('nodes.comments_create')
comment_url = flask.url_for('nodes_api.post_node_comment', node_path=str(self.node_id))
self.post(
comment_url,
data={
'content': 'je möder lives at [home](https://cloud.blender.org/)',
'parent_id': str(self.node_id),
json={
'msg': 'je möder lives at [home](https://cloud.blender.org/)',
},
expected_status=201,
)
@@ -51,14 +50,16 @@ class CommentEditTest(AbstractPillarTest):
super().setUp(**kwargs)
self.pid, self.project = self.ensure_project_exists()
self.uid = self.create_user(groups=[ctd.EXAMPLE_ADMIN_GROUP_ID])
self.create_valid_auth_token(self.uid, 'token')
self.owner_uid = self.create_user(24 * 'a',
groups=[ctd.EXAMPLE_ADMIN_GROUP_ID],
token='admin-token')
# Create a node people can comment on.
self.node_id = self.create_node({
'_id': ObjectId('572761099837730efe8e120d'),
'description': 'This is an asset without file',
'node_type': 'asset',
'user': self.uid,
'user': self.owner_uid,
'properties': {
'status': 'published',
'content_type': 'image',
@@ -67,31 +68,35 @@ class CommentEditTest(AbstractPillarTest):
'project': self.pid,
})
self.user_uid = self.create_user(24 * 'b', groups=[ctd.EXAMPLE_ADMIN_GROUP_ID],
token='user-token')
def test_edit_comment(self):
from pillar import auth
from pillar.web.nodes.custom import comments
# Create the comment
with self.app.test_request_context(method='POST', data={
'content': 'My first comment',
'parent_id': str(self.node_id),
}):
auth.login_user('token', load_from_db=True)
resp, status = comments.comments_create()
with self.login_as(self.user_uid):
comment_url = flask.url_for('nodes_api.post_node_comment', node_path=str(self.node_id))
resp = self.post(
comment_url,
json={
'msg': 'je möder lives at [home](https://cloud.blender.org/)',
},
expected_status=201,
)
self.assertEqual(201, status)
payload = json.loads(resp.data)
comment_id = payload['node_id']
payload = json.loads(resp.data)
comment_id = payload['id']
# Edit the comment
with self.app.test_request_context(method='POST', data={
'content': 'Edited comment',
}):
auth.login_user('token', load_from_db=True)
resp = comments.comment_edit(comment_id)
comment_url = flask.url_for('nodes_api.patch_node_comment', node_path=str(self.node_id), comment_path=comment_id)
# Edit the comment
resp = self.patch(
comment_url,
json={
'msg': 'Edited comment',
},
expected_status=200,
)
self.assertEqual(200, resp.status_code)
payload = json.loads(resp.data)
self.assertEqual('success', payload['status'])
self.assertEqual('Edited comment', payload['data']['content'])
self.assertEqual('<p>Edited comment</p>\n', payload['data']['content_html'])
self.assertEqual(200, resp.status_code)
payload = json.loads(resp.data)
self.assertEqual('Edited comment', payload['msg_markdown'])
self.assertEqual('<p>Edited comment</p>\n', payload['msg_html'])