add: backup version converter/ backup logic 1.0
This commit is contained in:
@@ -11,6 +11,21 @@ from db.models.MarkdownSetting import MarkdownSetting
|
||||
@limiter.limit(api.get_rate_limit)
|
||||
@etag_response
|
||||
def get_markdown_path(setting_id):
|
||||
"""
|
||||
Get a specific markdown setting by ID.
|
||||
|
||||
This endpoint retrieves a markdown setting by its ID.
|
||||
|
||||
Request:
|
||||
- setting_id (int): The ID of the markdown setting to retrieve
|
||||
|
||||
Returns:
|
||||
A JSON object containing the markdown setting.
|
||||
|
||||
Response Codes:
|
||||
- 200: Success
|
||||
- 204: No content (setting not found)
|
||||
"""
|
||||
with get_db() as session:
|
||||
setting = session.query(MarkdownSetting).get(setting_id)
|
||||
if setting is None:
|
||||
@@ -21,6 +36,23 @@ def get_markdown_path(setting_id):
|
||||
@setting_bp.route('/markdown/', methods=['POST'])
|
||||
@require_auth(roles=['admin'])
|
||||
def create_markdown_setting():
|
||||
"""
|
||||
Create a new markdown setting.
|
||||
|
||||
This endpoint creates a new markdown setting with the provided template and permission settings.
|
||||
It requires authentication with the 'admin' role.
|
||||
|
||||
Request:
|
||||
- template_setting_id (int, optional): The ID of the template setting to associate
|
||||
- permission_setting_id (int, optional): The ID of the permission setting to associate
|
||||
|
||||
Returns:
|
||||
A JSON object containing the created markdown setting.
|
||||
|
||||
Response Codes:
|
||||
- 200: Created successfully
|
||||
- 500: Server error
|
||||
"""
|
||||
data = request.json
|
||||
template_setting_id = data.get('template_setting_id')
|
||||
permission_setting_id = data.get('permission_setting_id')
|
||||
@@ -39,6 +71,25 @@ def create_markdown_setting():
|
||||
@setting_bp.route('/markdown/<int:setting_id>', methods=['PUT', 'PATCH'])
|
||||
@require_auth(roles=['admin'])
|
||||
def update_markdown_setting(setting_id):
|
||||
"""
|
||||
Update a markdown setting.
|
||||
|
||||
This endpoint updates an existing markdown setting with the provided template and permission settings.
|
||||
It requires authentication with the 'admin' role.
|
||||
|
||||
Request:
|
||||
- setting_id (int): The ID of the markdown setting to update
|
||||
- template_setting_id (int, optional): The new template setting ID
|
||||
- permission_setting_id (int, optional): The new permission setting ID
|
||||
|
||||
Returns:
|
||||
A JSON object containing the updated markdown setting.
|
||||
|
||||
Response Codes:
|
||||
- 200: Updated successfully
|
||||
- 400: Bad request (setting not found)
|
||||
- 500: Server error
|
||||
"""
|
||||
data = request.json
|
||||
try:
|
||||
with get_db() as session:
|
||||
@@ -58,6 +109,22 @@ def update_markdown_setting(setting_id):
|
||||
@setting_bp.route('/markdown/<int:setting_id>', methods=['DELETE'])
|
||||
@require_auth(roles=['admin'])
|
||||
def delete_markdown_setting(setting_id):
|
||||
"""
|
||||
Delete a markdown setting.
|
||||
|
||||
This endpoint deletes an existing markdown setting.
|
||||
It requires authentication with the 'admin' role.
|
||||
|
||||
Request:
|
||||
- setting_id (int): The ID of the markdown setting to delete
|
||||
|
||||
Returns:
|
||||
A JSON object with a success message.
|
||||
|
||||
Response Codes:
|
||||
- 200: Deleted successfully
|
||||
- 400: Bad request (setting not found)
|
||||
"""
|
||||
with get_db() as session:
|
||||
setting = session.query(MarkdownSetting).get(setting_id)
|
||||
if setting is None:
|
||||
|
||||
Reference in New Issue
Block a user