From 14cf5e84d3995c83ebe954af69e2cc209cf38f0b Mon Sep 17 00:00:00 2001 From: Matt Hills Date: Mon, 20 Oct 2025 23:14:48 -0400 Subject: [PATCH] Remove backward compatibility fields from product forms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove automatic addition of ProductName and Price fields when they're not defined as custom AR fields. This ensures tenants using only custom fields won't see unwanted default fields in their products. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/app/blueprints/admin/routes.py | 42 ----------------------- src/app/templates/admin/add_product.html | 20 +---------- src/app/templates/admin/edit_product.html | 30 +--------------- 3 files changed, 2 insertions(+), 90 deletions(-) diff --git a/src/app/blueprints/admin/routes.py b/src/app/blueprints/admin/routes.py index d9058a4..01c6bab 100644 --- a/src/app/blueprints/admin/routes.py +++ b/src/app/blueprints/admin/routes.py @@ -108,29 +108,6 @@ def add_product(tenant_id): "fieldType": field['fieldType'] }) - # Handle backward compatibility fields - if '_name' not in [f['fieldName'] for f in custom_fields]: - name = request.form.get('name', '') - if name: - product_data.append({ - "fieldName": "_name", - "label": "Product Name", - "value": name, - "editable": "true", - "fieldType": "TEXT" - }) - - if '_price' not in [f['fieldName'] for f in custom_fields]: - price = request.form.get('price', '') - if price: - product_data.append({ - "fieldName": "_price", - "label": "Sale Price", - "value": f"${price}", - "editable": "true", - "fieldType": "TEXT" - }) - # Save to database ProductModel.save(product_id, tenant_id, product_data, image_data, image_mime_type) @@ -235,25 +212,6 @@ def edit_product(tenant_id, product_id): updated_product.append(existing_field) - # Handle backward compatibility fields - if '_name' not in [f['fieldName'] for f in custom_fields]: - name = request.form.get('name', '') - if name: - for field in products[product_id]: - if field["fieldName"] == "_name": - field["value"] = name - updated_product.append(field) - break - - if '_price' not in [f['fieldName'] for f in custom_fields]: - price = request.form.get('price', '') - if price: - for field in products[product_id]: - if field["fieldName"] == "_price": - field["value"] = f"${price}" - updated_product.append(field) - break - # Save to database ProductModel.save(product_id, tenant_id, updated_product, image_data, image_mime_type) diff --git a/src/app/templates/admin/add_product.html b/src/app/templates/admin/add_product.html index 7df582f..4aac9f1 100644 --- a/src/app/templates/admin/add_product.html +++ b/src/app/templates/admin/add_product.html @@ -62,25 +62,7 @@ {% endif %} {% endfor %} - - - {% if not custom_fields|selectattr('fieldName', 'equalto', '_name')|list %} -
- - -
- {% endif %} - - {% if not custom_fields|selectattr('fieldName', 'equalto', '_price')|list %} -
- -
- $ - -
-
- {% endif %} - +
Cancel diff --git a/src/app/templates/admin/edit_product.html b/src/app/templates/admin/edit_product.html index a2f3680..9aa37fe 100644 --- a/src/app/templates/admin/edit_product.html +++ b/src/app/templates/admin/edit_product.html @@ -60,35 +60,7 @@
{% endif %} {% endfor %} - - - {% if not custom_fields|selectattr('fieldName', 'equalto', '_name')|list %} - {% for field in product %} - {% if field.fieldName == '_name' %} -
- - -
- {% endif %} - {% endfor %} - {% endif %} - - {% if not custom_fields|selectattr('fieldName', 'equalto', '_price')|list %} - {% for field in product %} - {% if field.fieldName == '_price' %} -
- -
- $ - {% set price_value = field.value|replace('$', '') %} - -
-
- {% endif %} - {% endfor %} - {% endif %} - +
Cancel