Fix dashboard -> http functions over view page not working on refresh (was sending html partial for htmx)

This commit is contained in:
Peter Stockings
2024-03-29 21:40:37 +11:00
parent cb3afa77fc
commit d25e8bb182
2 changed files with 12 additions and 4 deletions

8
app.py
View File

@@ -110,8 +110,11 @@ def dashboard_http_functions():
user_id = current_user.id
http_functions = db.get_http_functions_for_user(user_id)
http_functions = create_http_functions_view_model(http_functions)
if htmx:
return render_block(app.jinja_env, "dashboard/http_functions/overview.html", "page", http_functions=http_functions)
return render_template("dashboard/http_functions/overview.html", http_functions=http_functions)
@ app.route("/dashboard/http_functions/add_form", methods=["GET"])
@login_required
def get_http_function_add_form():
@@ -137,7 +140,7 @@ def create_http_function():
http_functions = db.get_http_functions_for_user(user_id)
http_functions = create_http_functions_view_model(http_functions)
return render_template("dashboard/http_functions/overview.html", http_functions=http_functions), 200, {"HX-Push-Url": url_for('dashboard_http_functions')}
return render_block(app.jinja_env, "dashboard/http_functions/overview.html", "page", http_functions=http_functions), 200, {"HX-Push-Url": url_for('dashboard_http_functions')}
except Exception as e:
print(e)
return { "status": "error", "message": str(e) }
@@ -184,12 +187,11 @@ def edit_http_function(function_id):
def delete_http_function(function_id):
try:
user_id = current_user.id
name = request.args.get('name')
db.delete_http_function(user_id, function_id)
http_functions = db.get_http_functions_for_user(user_id)
http_functions = create_http_functions_view_model(http_functions)
return render_template("dashboard/http_functions/overview.html", http_functions=http_functions), 200, {"HX-Push-Url": url_for('dashboard_http_functions')}
return render_block(app.jinja_env, "dashboard/http_functions/overview.html", "page", http_functions=http_functions), 200, {"HX-Push-Url": url_for('dashboard_http_functions')}
except Exception as e:
return jsonify({"status": 'error', "message": str(e)}), 500