Refactor settings logic; streamline brand and item type creation, enhance ComboBoxWidget integration for improved usability

This commit is contained in:
Yaro Kasear 2025-06-23 10:13:22 -05:00
parent c6fc1a4795
commit 347baaa12e
3 changed files with 40 additions and 35 deletions

View file

@ -411,6 +411,22 @@ def settings():
flash("Invalid form state submitted. JSON decode failed.", "danger")
traceback.print_exc()
return redirect(url_for('main.settings'))
# === 0. Create new Brands ===
for name in state.get('brands', []):
clean = name.strip()
if clean:
print(f"🧪 Creating new brand: {clean}")
new_brand = Brand(name=clean) # type: ignore
db.session.add(new_brand)
# === 0.5 Create new Types ===
for name in state.get('types', []):
clean = name.strip()
if clean:
print(f"🧪 Creating new item type: {clean}")
new_type = Item(description=clean) # type: ignore
db.session.add(new_type)
# === 1. Create new Sections ===
section_map = {}