summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/API.md9
-rw-r--r--server/szurubooru/func/pools.py6
-rw-r--r--server/szurubooru/func/posts.py2
-rw-r--r--server/szurubooru/tests/func/test_posts.py20
4 files changed, 15 insertions, 22 deletions
diff --git a/doc/API.md b/doc/API.md
index e75b993..11f2d5b 100644
--- a/doc/API.md
+++ b/doc/API.md
@@ -99,6 +99,7 @@
- [Micro post](#micro-post)
- [Pool category](#pool-category)
- [Pool](#pool)
+ - [Micro pool](#micro-pool)
- [Note](#note)
- [Comment](#comment)
- [Snapshot](#snapshot)
@@ -2455,7 +2456,7 @@ One file together with its metadata posted to the site.
- `<mime-type>`: subsidiary to `<type>`, used to tell exact content format;
useful for `<video>` tags for instance.
- `<comment>`: a [comment resource](#comment) for given post.
-- `<pool>`: a [pool resource](#pool) for given post.
+- `<pool>`: a [micro pool resource](#micro-pool) in which the post is a member of.
## Micro post
**Description**
@@ -2545,6 +2546,12 @@ An ordered list of posts, with a description and category.
- `<description>`: the pool description (instructions how to use, history etc.)
The client should render it as Markdown.
+## Micro pool
+**Description**
+
+A [pool resource](#pool) stripped down to `id`, `names`, `category`,
+`description` and `postCount` fields.
+
## Comment
**Description**
diff --git a/server/szurubooru/func/pools.py b/server/szurubooru/func/pools.py
index 8bd5090..c3ea9f0 100644
--- a/server/szurubooru/func/pools.py
+++ b/server/szurubooru/func/pools.py
@@ -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)
diff --git a/server/szurubooru/func/posts.py b/server/szurubooru/func/posts.py
index 67996b6..e964d97 100644
--- a/server/szurubooru/func/posts.py
+++ b/server/szurubooru/func/posts.py
@@ -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
)
diff --git a/server/szurubooru/tests/func/test_posts.py b/server/szurubooru/tests/func/test_posts.py
index d088b9b..0a5940b 100644
--- a/server/szurubooru/tests/func/test_posts.py
+++ b/server/szurubooru/tests/func/test_posts.py
@@ -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",