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:
|
||||
|
||||
@@ -10,6 +10,21 @@ from db.models.MarkdownPermissionSetting import MarkdownPermissionSetting
|
||||
@etag_response
|
||||
@limiter.limit(api.get_rate_limit)
|
||||
def get_permission_setting(setting_id):
|
||||
"""
|
||||
Get a specific markdown permission setting by ID.
|
||||
|
||||
This endpoint retrieves a markdown permission setting by its ID.
|
||||
|
||||
Request:
|
||||
- setting_id (int): The ID of the permission setting to retrieve
|
||||
|
||||
Returns:
|
||||
A JSON object containing the permission setting.
|
||||
|
||||
Response Codes:
|
||||
- 200: Success
|
||||
- 204: No content (setting not found)
|
||||
"""
|
||||
with get_db() as session:
|
||||
setting = session.query(MarkdownPermissionSetting).get(setting_id)
|
||||
if not setting:
|
||||
@@ -20,6 +35,21 @@ def get_permission_setting(setting_id):
|
||||
@setting_bp.route('/markdown/permission/', methods=['POST'])
|
||||
@require_auth(roles=['admin'])
|
||||
def create_permission_setting():
|
||||
"""
|
||||
Create a new markdown permission setting.
|
||||
|
||||
This endpoint creates a new markdown permission setting with the provided permission value.
|
||||
It requires authentication with the 'admin' role.
|
||||
|
||||
Request:
|
||||
- permission (str): The permission value (e.g., 'private', 'protected', etc.)
|
||||
|
||||
Returns:
|
||||
A JSON object containing the created permission setting.
|
||||
|
||||
Response Codes:
|
||||
- 201: Created successfully
|
||||
"""
|
||||
data = request.json
|
||||
permission = data.get('permission')
|
||||
new_setting = MarkdownPermissionSetting(permission=permission)
|
||||
@@ -32,6 +62,26 @@ def create_permission_setting():
|
||||
@setting_bp.route('/markdown/permission/<int:setting_id>', methods=['PUT', 'PATCH'])
|
||||
@require_auth(roles=['admin'])
|
||||
def update_permission_setting(setting_id):
|
||||
"""
|
||||
Update a markdown permission setting.
|
||||
|
||||
This endpoint updates an existing markdown permission setting with the provided permission value.
|
||||
It requires authentication with the 'admin' role.
|
||||
|
||||
- PUT: Replaces the entire permission setting
|
||||
- PATCH: Updates only the specified fields
|
||||
|
||||
Request:
|
||||
- setting_id (int): The ID of the permission setting to update
|
||||
- permission (str): The new permission value
|
||||
|
||||
Returns:
|
||||
A JSON object containing the updated permission setting.
|
||||
|
||||
Response Codes:
|
||||
- 200: Updated successfully
|
||||
- 404: Permission setting not found
|
||||
"""
|
||||
with get_db() as session:
|
||||
setting = session.get(MarkdownPermissionSetting, setting_id)
|
||||
if setting is None:
|
||||
@@ -48,6 +98,21 @@ def update_permission_setting(setting_id):
|
||||
@setting_bp.route('/markdown/permission/<int:setting_id>', methods=['DELETE'])
|
||||
@require_auth(roles=['admin'])
|
||||
def delete_permission_setting(setting_id):
|
||||
"""
|
||||
Delete a markdown permission setting.
|
||||
|
||||
This endpoint deletes an existing markdown permission setting.
|
||||
It requires authentication with the 'admin' role.
|
||||
|
||||
Request:
|
||||
- setting_id (int): The ID of the permission setting to delete
|
||||
|
||||
Returns:
|
||||
A JSON object containing the deleted permission setting.
|
||||
|
||||
Response Codes:
|
||||
- 200: Deleted successfully
|
||||
"""
|
||||
with get_db() as session:
|
||||
setting = session.get(MarkdownPermissionSetting, setting_id)
|
||||
st = setting.to_dict()
|
||||
|
||||
@@ -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