add: backup version converter/ backup logic 1.0
This commit is contained in:
@@ -9,6 +9,17 @@ from db.models.MarkdownTemplateSetting import MarkdownTemplateSetting
|
||||
@setting_bp.route('/markdown/template/', methods=['GET'])
|
||||
@etag_response
|
||||
def list_template_settings():
|
||||
"""
|
||||
List all markdown template settings.
|
||||
|
||||
This endpoint retrieves a list of all markdown template settings in the system.
|
||||
|
||||
Returns:
|
||||
A JSON array containing all template settings.
|
||||
|
||||
Response Codes:
|
||||
- 200: Success
|
||||
"""
|
||||
with get_db() as session:
|
||||
settings = session.query(MarkdownTemplateSetting).all()
|
||||
return jsonify([s.to_dict() for s in settings]), 200
|
||||
@@ -17,6 +28,21 @@ def list_template_settings():
|
||||
@etag_response
|
||||
@limiter.limit(api.get_rate_limit)
|
||||
def get_template_setting(setting_id):
|
||||
"""
|
||||
Get a specific markdown template setting by ID.
|
||||
|
||||
This endpoint retrieves a markdown template setting by its ID.
|
||||
|
||||
Request:
|
||||
- setting_id (int): The ID of the template setting to retrieve
|
||||
|
||||
Returns:
|
||||
A JSON object containing the template setting.
|
||||
|
||||
Response Codes:
|
||||
- 200: Success
|
||||
- 204: No content (setting not found)
|
||||
"""
|
||||
with get_db() as session:
|
||||
setting = session.query(MarkdownTemplateSetting).get(setting_id)
|
||||
if not setting:
|
||||
@@ -27,6 +53,21 @@ def get_template_setting(setting_id):
|
||||
@setting_bp.route('/markdown/template/', methods=['POST'])
|
||||
@require_auth(roles=['admin'])
|
||||
def create_template_setting():
|
||||
"""
|
||||
Create a new markdown template setting.
|
||||
|
||||
This endpoint creates a new markdown template setting with the provided template ID.
|
||||
It requires authentication with the 'admin' role.
|
||||
|
||||
Request:
|
||||
- template_id (int): The ID of the template to associate with this setting
|
||||
|
||||
Returns:
|
||||
A JSON object containing the created template setting.
|
||||
|
||||
Response Codes:
|
||||
- 201: Created successfully
|
||||
"""
|
||||
data = request.json
|
||||
template_id = data.get('template_id')
|
||||
new_setting = MarkdownTemplateSetting(template_id=template_id)
|
||||
@@ -39,6 +80,26 @@ def create_template_setting():
|
||||
@setting_bp.route('/markdown/template/<int:setting_id>', methods=['PUT', 'PATCH'])
|
||||
@require_auth(roles=['admin'])
|
||||
def update_template_setting(setting_id):
|
||||
"""
|
||||
Update a markdown template setting.
|
||||
|
||||
This endpoint updates an existing markdown template setting with the provided template ID.
|
||||
It requires authentication with the 'admin' role.
|
||||
|
||||
- PUT: Replaces the entire template setting
|
||||
- PATCH: Updates only the specified fields
|
||||
|
||||
Request:
|
||||
- setting_id (int): The ID of the template setting to update
|
||||
- template_id (int): The new template ID
|
||||
|
||||
Returns:
|
||||
A JSON object containing the updated template setting.
|
||||
|
||||
Response Codes:
|
||||
- 200: Updated successfully
|
||||
- 404: Template setting not found
|
||||
"""
|
||||
with get_db() as session:
|
||||
setting = session.get(MarkdownTemplateSetting, setting_id)
|
||||
if setting is None:
|
||||
@@ -55,6 +116,21 @@ def update_template_setting(setting_id):
|
||||
@setting_bp.route('/markdown/template/<int:setting_id>', methods=['DELETE'])
|
||||
@require_auth(roles=['admin'])
|
||||
def delete_template_setting(setting_id):
|
||||
"""
|
||||
Delete a markdown template setting.
|
||||
|
||||
This endpoint deletes an existing markdown template setting.
|
||||
It requires authentication with the 'admin' role.
|
||||
|
||||
Request:
|
||||
- setting_id (int): The ID of the template setting to delete
|
||||
|
||||
Returns:
|
||||
A JSON object containing the deleted template setting.
|
||||
|
||||
Response Codes:
|
||||
- 200: Deleted successfully
|
||||
"""
|
||||
with get_db() as session:
|
||||
setting = session.get(MarkdownTemplateSetting, setting_id)
|
||||
st = setting.to_dict()
|
||||
|
||||
Reference in New Issue
Block a user