server/notes: fix note serialization
This commit is contained in:
parent
ba6c9645fb
commit
4d1f745e38
3 changed files with 6 additions and 4 deletions
|
@ -57,7 +57,7 @@ def get_post_thumbnail_backup_path(post):
|
|||
|
||||
def serialize_note(note):
|
||||
return {
|
||||
'polygon': note.path,
|
||||
'polygon': note.polygon,
|
||||
'text': note.text,
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,9 @@ def serialize_post(post, authenticated_user):
|
|||
'flags': post.flags,
|
||||
'tags': [tag.first_name for tag in post.tags],
|
||||
'relations': [rel.post_id for rel in post.relations],
|
||||
'notes': sorted(serialize_note(note) for note in post.notes),
|
||||
'notes': sorted(
|
||||
[ serialize_note(note) for note in post.notes],
|
||||
key=lambda x: x['polygon']),
|
||||
'user': users.serialize_user(post.user, authenticated_user),
|
||||
'score': post.score,
|
||||
'featureCount': post.feature_count,
|
||||
|
|
|
@ -19,7 +19,7 @@ def get_post_snapshot(post):
|
|||
'notes': sorted([{
|
||||
'polygon': note.polygon,
|
||||
'text': note.text,
|
||||
} for note in post.notes]),
|
||||
} for note in post.notes], key=lambda x: x['polygon']),
|
||||
'flags': post.flags,
|
||||
'featured': post.is_featured,
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ def test_get_post_thumbnail_backup_path(input_mime_type):
|
|||
|
||||
def test_serialize_note():
|
||||
note = db.PostNote()
|
||||
note.path = [[0, 1], [1, 1], [1, 0], [0, 0]]
|
||||
note.polygon = [[0, 1], [1, 1], [1, 0], [0, 0]]
|
||||
note.text = '...'
|
||||
assert posts.serialize_note(note) == {
|
||||
'polygon': [[0, 1], [1, 1], [1, 0], [0, 0]],
|
||||
|
|
Loading…
Reference in a new issue