mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
server/posts: add ownFavorite field to posts
This commit is contained in:
@ -93,6 +93,9 @@ def serialize_post(post, authenticated_user, options=None):
|
||||
'user': lambda: users.serialize_micro_user(post.user),
|
||||
'score': lambda: post.score,
|
||||
'ownScore': lambda: scores.get_score(post, authenticated_user),
|
||||
'ownFavorite': lambda: len(
|
||||
[user for user in post.favorited_by \
|
||||
if user.user_id == authenticated_user.user_id]) > 0,
|
||||
'tagCount': lambda: post.tag_count,
|
||||
'favoriteCount': lambda: post.favorite_count,
|
||||
'commentCount': lambda: post.comment_count,
|
||||
|
@ -147,6 +147,7 @@ def test_serialize_post(
|
||||
'notes': [],
|
||||
'user': 'post author',
|
||||
'score': 1,
|
||||
'ownFavorite': False,
|
||||
'ownScore': -1,
|
||||
'tagCount': 2,
|
||||
'favoriteCount': 1,
|
||||
|
Reference in New Issue
Block a user