fix(critical): SQLAlchemy mapper crash + material matching for USD renders + kanban drag-to-reject

- beat_tasks.py: import app.models at module level so SQLAlchemy can
  resolve relationship("Template") and relationship("User") when domain
  models are imported in isolation inside task functions. Fixes all
  beat tasks (batch_render_notifications, recover_stuck_cad_files) that
  crashed every 60s with mapper initialization error.

- _blender_materials.py: build_mat_map_lower() now adds a slug-normalized
  key variant (re.sub([^a-z0-9]+, _, kl)) for each mat_map entry. OCC
  part names like 'F-802007_TR4-D1-H122AG' → slug 'f_802007_tr4_d1_h122ag'
  now matches USD-imported Blender objects. Existing prefix fallback
  (key.startswith(part_key)) catches AF-suffix variants.

- Orders.tsx: kanban drag-to-reject implemented. submitted/processing
  cards are draggable (cursor-grab). Rejected column highlights with
  red ring on drag-over. Drop opens reject reason modal via createPortal.
  Confirm calls rejectOrder() mutation + invalidates orders cache.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 22:21:46 +01:00
parent 71584edce6
commit 8e1cd41868
4 changed files with 134 additions and 7 deletions
@@ -38,6 +38,14 @@ def build_mat_map_lower(material_map: dict) -> dict:
for k, v in material_map.items():
kl = k.lower().strip()
mat_map_lower[kl] = v
# USD path: part_key slugs replace ALL non-alphanumeric chars with '_'
# (same regex as generate_part_key in export_step_to_usd.py).
# E.g. "F-802007_TR4-D1" → "f_802007_tr4_d1". Add slug variant so
# hyphenated OCC names match USD-imported Blender objects.
slug_key = _re.sub(r'[^a-z0-9]+', '_', kl).strip('_')
if slug_key and slug_key != kl:
mat_map_lower.setdefault(slug_key, v)
# _AF\d+ stripping for GLB object names
stripped = kl
prev = None
while prev != stripped: