upgrade react-query to v5
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
from flask import jsonify, request
|
||||
from flask import jsonify, request, Blueprint
|
||||
from api import etag_response, require_auth
|
||||
from api.template import template_bp
|
||||
from db import get_db
|
||||
from db.models.MarkdownTemplate import MarkdownTemplate
|
||||
|
||||
cached_templates = {}
|
||||
|
||||
markdown_template_bp = Blueprint('markdown_template', __name__, url_prefix='/api/template/markdown')
|
||||
|
||||
def inflate_template(template):
|
||||
for parameter in template.get('parameters'):
|
||||
if parameter.get('type', {}).get('base_type') == 'template':
|
||||
@@ -19,7 +21,7 @@ def inflate_template(template):
|
||||
return template
|
||||
|
||||
|
||||
@template_bp.route('/markdown/<int:template_id>', methods=['GET'])
|
||||
@markdown_template_bp.route('/<int:template_id>', methods=['GET'])
|
||||
@etag_response
|
||||
def get_markdown_template(template_id):
|
||||
"""
|
||||
@@ -42,10 +44,9 @@ def get_markdown_template(template_id):
|
||||
template = session.query(MarkdownTemplate).get(template_id)
|
||||
if template is None:
|
||||
return jsonify({}), 204
|
||||
print(inflate_template(template.to_dict()))
|
||||
return jsonify(inflate_template(template.to_dict())), 200
|
||||
|
||||
@template_bp.route('/markdown/', methods=['GET'])
|
||||
@markdown_template_bp.route('/', methods=['GET'])
|
||||
@etag_response
|
||||
def get_markdown_templates():
|
||||
"""
|
||||
@@ -62,11 +63,10 @@ def get_markdown_templates():
|
||||
"""
|
||||
with get_db() as session:
|
||||
templates = session.query(MarkdownTemplate).all()
|
||||
print(templates)
|
||||
return jsonify([inflate_template(template.to_dict()) for template in templates]), 200
|
||||
|
||||
|
||||
@template_bp.route('/markdown/', methods=['POST'])
|
||||
@markdown_template_bp.route('/', methods=['POST'])
|
||||
@require_auth(roles=['admin'])
|
||||
def create_markdown_template():
|
||||
"""
|
||||
@@ -103,7 +103,7 @@ def create_markdown_template():
|
||||
return jsonify({"error": "failed to create markdown template"}), 400
|
||||
|
||||
|
||||
@template_bp.route('/markdown/<int:template_id>', methods=['PUT', 'PATCH'])
|
||||
@markdown_template_bp.route('/<int:template_id>', methods=['PUT', 'PATCH'])
|
||||
@require_auth(roles=['admin'])
|
||||
def update_markdown_template(template_id):
|
||||
"""
|
||||
@@ -142,7 +142,7 @@ def update_markdown_template(template_id):
|
||||
return jsonify(template.to_dict()), 200
|
||||
|
||||
|
||||
@template_bp.route('/markdown/<int:template_id>', methods=['DELETE'])
|
||||
@markdown_template_bp.route('/<int:template_id>', methods=['DELETE'])
|
||||
@require_auth(roles=['admin'])
|
||||
def delete_markdown_template(template_id):
|
||||
"""
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
from flask import jsonify, request
|
||||
from flask.sansio.blueprints import Blueprint
|
||||
|
||||
from api import etag_response, require_auth
|
||||
from api.template import template_bp
|
||||
from db import get_db
|
||||
from db.models.PathTemplate import PathTemplate
|
||||
|
||||
|
||||
@template_bp.route('/path/<int:template_id>', methods=['GET'])
|
||||
path_template_bp = Blueprint('path_template', __name__, url_prefix='/api/template/path')
|
||||
@path_template_bp.route('/<int:template_id>', methods=['GET'])
|
||||
@etag_response
|
||||
def get_path_template(template_id):
|
||||
"""
|
||||
@@ -30,7 +31,7 @@ def get_path_template(template_id):
|
||||
return jsonify({}), 204
|
||||
return jsonify(template.to_dict()), 200
|
||||
|
||||
@template_bp.route('/path/', methods=['GET'])
|
||||
@path_template_bp.route('/', methods=['GET'])
|
||||
@etag_response
|
||||
def get_path_templates():
|
||||
"""
|
||||
@@ -49,7 +50,7 @@ def get_path_templates():
|
||||
return jsonify([template.to_dict() for template in templates]), 200
|
||||
|
||||
|
||||
@template_bp.route('/path/', methods=['POST'])
|
||||
@path_template_bp.route('/', methods=['POST'])
|
||||
@require_auth(roles=['admin'])
|
||||
def create_path_template():
|
||||
"""
|
||||
@@ -84,7 +85,7 @@ def create_path_template():
|
||||
return jsonify({"error": "failed to create path template"}), 400
|
||||
|
||||
|
||||
@template_bp.route('/path/<int:template_id>', methods=['PUT', 'PATCH'])
|
||||
@path_template_bp.route('/<int:template_id>', methods=['PUT', 'PATCH'])
|
||||
@require_auth(roles=['admin'])
|
||||
def update_path_template(template_id):
|
||||
"""
|
||||
@@ -118,7 +119,7 @@ def update_path_template(template_id):
|
||||
return jsonify(template.to_dict()), 200
|
||||
|
||||
|
||||
@template_bp.route('/path/<int:template_id>', methods=['DELETE'])
|
||||
@path_template_bp.route('/<int:template_id>', methods=['DELETE'])
|
||||
@require_auth(roles=['admin'])
|
||||
def delete_path_template(template_id):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user