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:
2025-10-20 21:36:01 -04:00
parent a727796ed2
commit 03b4264239
4 changed files with 37 additions and 1 deletions

View File

@@ -16,6 +16,18 @@
<hr class="my-4">
<div class="mt-4">
{% if not custom_fields %}
<div class="alert alert-warning" role="alert">
<h4 class="alert-heading"><i class="bi bi-exclamation-triangle-fill me-2"></i>No AR Fields Configured</h4>
<p>Before you can add products, you need to configure custom AR fields that define what information is returned for each product.</p>
<hr>
<p class="mb-0">
<a href="/{{ tenant.id }}/ar_fields" class="btn btn-primary">
<i class="bi bi-gear-fill me-1"></i>Configure AR Fields
</a>
</p>
</div>
{% else %}
<div class="d-flex justify-content-between align-items-center mb-3">
<h2>Products</h2>
<div>
@@ -27,7 +39,7 @@
</a>
</div>
</div>
{% if products %}
<div class="table-responsive">
<table class="table table-striped table-hover">
@@ -91,6 +103,7 @@
<i class="bi bi-info-circle"></i> No products available yet. Click "Add New Product" to get started.
</div>
{% endif %}
{% endif %}
</div>
<div class="mt-4">