diff --git a/frontend_multi_user/src/admin_routes.py b/frontend_multi_user/src/admin_routes.py index 8d7169cda..b44504859 100644 --- a/frontend_multi_user/src/admin_routes.py +++ b/frontend_multi_user/src/admin_routes.py @@ -406,9 +406,9 @@ def generate(): return response -@admin_routes_bp.route("/demo_run") +@admin_routes_bp.route("/admin/demo_run") @_admin_required -def demo_run(): +def admin_demo_run(): from src.app import _model_profile_options, DEMO_FORM_RUN_PROMPT_UUIDS user_id = str(current_user.id) nonce = "DEMO_" + str(uuid.uuid4()) @@ -417,14 +417,18 @@ def demo_run(): for prompt_uuid in DEMO_FORM_RUN_PROMPT_UUIDS: prompt_item = prompt_catalog.find(prompt_uuid) if prompt_item is None: - logger.error(f"Prompt item not found for uuid: {prompt_uuid} in demo_run") + logger.error(f"Prompt item not found for uuid: {prompt_uuid} in admin_demo_run") return "Error: Demo prompt configuration missing.", 500 prompts.append(prompt_item.prompt) - return render_template( - "demo_run.html", + admin_ext = current_app.extensions.get("admin", [None]) + admin_obj = admin_ext[0] if isinstance(admin_ext, list) and admin_ext else None + template_args = dict( user_id=user_id, prompts=prompts, nonce=nonce, model_profile_options=_model_profile_options(), ) + if admin_obj: + return admin_obj.index_view.render("admin/demo_run.html", **template_args) + return render_template("admin/demo_run.html", **template_args) diff --git a/frontend_multi_user/src/plan_routes.py b/frontend_multi_user/src/plan_routes.py index b741962b6..6744bb958 100644 --- a/frontend_multi_user/src/plan_routes.py +++ b/frontend_multi_user/src/plan_routes.py @@ -626,8 +626,9 @@ def run(): ) if current_user.is_admin: - admin_account = _get_current_user_account() - user_id_param = str(admin_account.id) if admin_account else current_app.config["ADMIN_USERNAME"] + if not user_id_param: + admin_account = _get_current_user_account() + user_id_param = str(admin_account.id) if admin_account else current_app.config["ADMIN_USERNAME"] else: user_id_param = str(current_user.id) diff --git a/frontend_multi_user/templates/admin/demo_run.html b/frontend_multi_user/templates/admin/demo_run.html new file mode 100644 index 000000000..4f54cc24d --- /dev/null +++ b/frontend_multi_user/templates/admin/demo_run.html @@ -0,0 +1,279 @@ +{% extends 'admin/master.html' %} + +{% block head_css %} + {{ super() }} + +{% endblock %} + +{% block body %} + {{ super() }} +