fix: auto-create PageConfig when enabling page features
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 36s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 36s
When toggling market/calendar features or saving SumUp settings, create a PageConfig row if one doesn't exist yet instead of returning a 404 error. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user