diff --git a/bp/post/admin/routes.py b/bp/post/admin/routes.py index 5e1accd..afe6ab6 100644 --- a/bp/post/admin/routes.py +++ b/bp/post/admin/routes.py @@ -74,12 +74,14 @@ def register(): post_id = post["id"] - # Load PageConfig + # Load or create PageConfig pc = (await g.s.execute( sa_select(PageConfig).where(PageConfig.post_id == post_id) )).scalar_one_or_none() if pc is None: - return jsonify({"error": "PageConfig not found for this page."}), 404 + pc = PageConfig(post_id=post_id, features={}) + g.s.add(pc) + await g.s.flush() # Parse request body body = await request.get_json() @@ -139,7 +141,9 @@ def register(): sa_select(PageConfig).where(PageConfig.post_id == post_id) )).scalar_one_or_none() if pc is None: - return jsonify({"error": "PageConfig not found for this page."}), 404 + pc = PageConfig(post_id=post_id, features={}) + g.s.add(pc) + await g.s.flush() form = await request.form merchant_code = (form.get("merchant_code") or "").strip()