mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
server/snapshots: add snapshot lists
This commit is contained in:
17
server/szurubooru/api/snapshot_api.py
Normal file
17
server/szurubooru/api/snapshot_api.py
Normal file
@ -0,0 +1,17 @@
|
||||
from szurubooru import search
|
||||
from szurubooru.api.base_api import BaseApi
|
||||
from szurubooru.func import auth, snapshots
|
||||
|
||||
def _serialize_snapshot(snapshot):
|
||||
earlier_snapshot = snapshots.get_previous_snapshot(snapshot)
|
||||
return snapshots.serialize_snapshot(snapshot, earlier_snapshot)
|
||||
|
||||
class SnapshotListApi(BaseApi):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._search_executor = search.SearchExecutor(search.SnapshotSearchConfig())
|
||||
|
||||
def get(self, ctx):
|
||||
auth.verify_privilege(ctx.user, 'snapshots:list')
|
||||
return self._search_executor.execute_and_serialize(
|
||||
ctx, _serialize_snapshot, 'snapshots')
|
Reference in New Issue
Block a user