Add versions for http_functions, whenever script is updated a new version is logged.
This commit is contained in:
11
app.py
11
app.py
@@ -158,10 +158,11 @@ def get_http_function_edit_form(function_id):
|
||||
is_public = http_function['is_public']
|
||||
log_request = http_function['log_request']
|
||||
log_response = http_function['log_response']
|
||||
version_number = http_function['version_number']
|
||||
|
||||
if htmx:
|
||||
return render_block(app.jinja_env, 'dashboard/http_functions/edit.html', 'page', user_id=user_id, function_id=function_id, name=name, script=script, environment_info=environment_info, is_public=is_public, log_request=log_request, log_response=log_response)
|
||||
return render_template("dashboard/http_functions/edit.html", user_id=user_id, name=name, function_id=function_id, script=script, environment_info=environment_info, is_public=is_public, log_request=log_request, log_response=log_response)
|
||||
return render_block(app.jinja_env, 'dashboard/http_functions/edit.html', 'page', user_id=user_id, function_id=function_id, name=name, script=script, environment_info=environment_info, is_public=is_public, log_request=log_request, log_response=log_response, version_number=version_number)
|
||||
return render_template("dashboard/http_functions/edit.html", user_id=user_id, name=name, function_id=function_id, script=script, environment_info=environment_info, is_public=is_public, log_request=log_request, log_response=log_response, version_number=version_number)
|
||||
|
||||
@ app.route("/dashboard/http_functions/<int:function_id>/edit", methods=["POST"])
|
||||
@login_required
|
||||
@@ -175,7 +176,7 @@ def edit_http_function(function_id):
|
||||
log_request = request.json.get('log_request')
|
||||
log_response = request.json.get('log_response')
|
||||
|
||||
db.edit_http_function(user_id, function_id, name, script_content, environment_info, is_public, log_request, log_response)
|
||||
updated_version = db.edit_http_function(user_id, function_id, name, script_content, environment_info, is_public, log_request, log_response)
|
||||
|
||||
return { "status": "success", "message": f'{name} updated' }
|
||||
except Exception as e:
|
||||
@@ -275,6 +276,7 @@ def execute_http_function(user_id, function):
|
||||
is_public = http_function['is_public']
|
||||
log_request = http_function['log_request']
|
||||
log_response = http_function['log_response']
|
||||
version_number = http_function['version_number']
|
||||
|
||||
# Check if the function is public, if not check if the user is authenticated and owns the function
|
||||
if not is_public:
|
||||
@@ -323,7 +325,8 @@ def execute_http_function(user_id, function):
|
||||
response_data['status'],
|
||||
request_data if log_request else {},
|
||||
response_data['result'] if (log_response or response_data['status'] != 'SUCCESS') else {},
|
||||
response_data['logs'])
|
||||
response_data['logs'],
|
||||
version_number)
|
||||
|
||||
if response_data['status'] != 'SUCCESS':
|
||||
return render_template("function_error.html", function_name=function_name ,error=response_data['result'], logs=response_data['logs'])
|
||||
|
||||
Reference in New Issue
Block a user