mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
server/pools: serialize pools as micro resource within post resources
Fixes #348
This commit is contained in:
@ -152,6 +152,12 @@ def serialize_pool(
|
||||
return PoolSerializer(pool).serialize(options)
|
||||
|
||||
|
||||
def serialize_micro_pool(pool: model.Pool) -> Optional[rest.Response]:
|
||||
return serialize_pool(
|
||||
pool, options=["id", "names", "category", "description", "postCount"]
|
||||
)
|
||||
|
||||
|
||||
def try_get_pool_by_id(pool_id: int) -> Optional[model.Pool]:
|
||||
return (
|
||||
db.session.query(model.Pool)
|
||||
|
@ -334,7 +334,7 @@ class PostSerializer(serialization.BaseSerializer):
|
||||
|
||||
def serialize_pools(self) -> List[Any]:
|
||||
return [
|
||||
pools.serialize_pool(pool)
|
||||
pools.serialize_micro_pool(pool)
|
||||
for pool in sorted(
|
||||
self.post.pools, key=lambda pool: pool.creation_time
|
||||
)
|
||||
|
@ -247,16 +247,6 @@ def test_serialize_post(
|
||||
"description": "desc",
|
||||
"category": "test-cat1",
|
||||
"postCount": 1,
|
||||
"posts": [
|
||||
{
|
||||
"id": 1,
|
||||
"thumbnailUrl": "http://example.com/"
|
||||
"generated-thumbnails/1_244c8840887984c4.jpg",
|
||||
}
|
||||
],
|
||||
"version": 1,
|
||||
"creationTime": datetime(1996, 1, 1),
|
||||
"lastEditTime": datetime(1998, 1, 1),
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
@ -264,16 +254,6 @@ def test_serialize_post(
|
||||
"description": "desc2",
|
||||
"category": "test-cat2",
|
||||
"postCount": 1,
|
||||
"posts": [
|
||||
{
|
||||
"id": 1,
|
||||
"thumbnailUrl": "http://example.com/"
|
||||
"generated-thumbnails/1_244c8840887984c4.jpg",
|
||||
}
|
||||
],
|
||||
"version": 1,
|
||||
"creationTime": datetime(1996, 1, 1),
|
||||
"lastEditTime": datetime(1998, 1, 1),
|
||||
},
|
||||
],
|
||||
"user": "post author",
|
||||
|
Reference in New Issue
Block a user