add: backup version converter/ backup logic 1.0
This commit is contained in:
46
api/tree.py
46
api/tree.py
@@ -1,16 +1,15 @@
|
||||
from flask import Blueprint, request, jsonify
|
||||
from flask import Blueprint, jsonify
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy import and_, or_
|
||||
from sqlalchemy import or_
|
||||
|
||||
import api
|
||||
from api import etag_response, verify_token, is_user_admin
|
||||
from api import etag_response, is_user_admin
|
||||
from db import get_db
|
||||
from db.models.Markdown import Markdown
|
||||
from db.models.Path import Path
|
||||
from db.models.MarkdownSetting import MarkdownSetting
|
||||
from db.models.MarkdownPermissionSetting import MarkdownPermissionSetting
|
||||
from api import limiter
|
||||
import env_provider
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -67,6 +66,45 @@ def build_tree(db: Session, parent_id: int = None, is_admin=False):
|
||||
@limiter.limit(api.get_rate_limit)
|
||||
@etag_response
|
||||
def get_tree():
|
||||
"""
|
||||
Get the complete tree structure of paths and markdowns.
|
||||
|
||||
This endpoint retrieves the hierarchical tree structure of all paths and markdowns.
|
||||
For non-admin users, markdowns with 'private' permission settings are filtered out.
|
||||
|
||||
Returns:
|
||||
A JSON object representing the tree structure with the following format:
|
||||
{
|
||||
"id": 1,
|
||||
"name": "",
|
||||
"parent_id": null,
|
||||
"order": "...",
|
||||
"setting_id": null,
|
||||
"type": "path",
|
||||
"index": true/false,
|
||||
"children": [
|
||||
{
|
||||
"id": ...,
|
||||
"title": "...",
|
||||
"order": "...",
|
||||
"setting_id": null,
|
||||
"type": "markdown"
|
||||
},
|
||||
{
|
||||
"id": ...,
|
||||
"name": "...",
|
||||
"parent_id": 1,
|
||||
"order": "...",
|
||||
"setting_id": null,
|
||||
"type": "path",
|
||||
"children": [...]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Response Codes:
|
||||
- 200: Success
|
||||
"""
|
||||
is_admin = is_user_admin()
|
||||
|
||||
with get_db() as session:
|
||||
|
||||
Reference in New Issue
Block a user