diff options
| author | rr- <rr-@sakuya.pl> | 2016-05-07 21:42:03 +0200 |
|---|---|---|
| committer | rr- <rr-@sakuya.pl> | 2016-05-07 21:50:37 +0200 |
| commit | 58964bcdc9cfeccd72a017fdbd2f4ffc8ba7b6f3 (patch) | |
| tree | 1996c877f0ad62e56605fe259a6cd6294bcb59e7 /server/szurubooru/api/post_api.py | |
| parent | 9b591c3f1ba36f8aabee57d7ce46457acbb20794 (diff) | |
server/posts: add post listing
Diffstat (limited to 'server/szurubooru/api/post_api.py')
| -rw-r--r-- | server/szurubooru/api/post_api.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/server/szurubooru/api/post_api.py b/server/szurubooru/api/post_api.py index ed049f3..e848555 100644 --- a/server/szurubooru/api/post_api.py +++ b/server/szurubooru/api/post_api.py @@ -1,8 +1,19 @@ import datetime +from szurubooru import search from szurubooru.api.base_api import BaseApi from szurubooru.func import auth, tags, posts, snapshots, favorites, scores class PostListApi(BaseApi): + def __init__(self): + super().__init__() + self._search_executor = search.SearchExecutor(search.PostSearchConfig()) + + def get(self, ctx): + auth.verify_privilege(ctx.user, 'posts:list') + self._search_executor.config.user = ctx.user + return self._search_executor.execute_and_serialize( + ctx, lambda post: posts.serialize_post(post, ctx.user)) + def post(self, ctx): auth.verify_privilege(ctx.user, 'posts:create') content = ctx.get_file('content', required=True) |