Fix foreign key cascades and add validation for missing AR fields
- Enable SQLite foreign key constraints to properly cascade deletes - Add validation to prevent adding products when no AR fields configured - Display helpful warnings on product pages when fields are missing - Redirect users to AR field configuration when needed
This commit is contained in:
@@ -10,6 +10,11 @@ def add_product(tenant_id):
|
||||
"""Add a new product"""
|
||||
custom_fields = ARFieldModel.get_all(tenant_id)
|
||||
|
||||
# Prevent adding products if no fields are configured
|
||||
if not custom_fields:
|
||||
flash('Cannot add products. Please configure AR fields first.', 'warning')
|
||||
return redirect(url_for('admin.manage_ar_fields', tenant_id=tenant_id))
|
||||
|
||||
if request.method == 'POST':
|
||||
product_id = request.form.get('product_id')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user