Preis-Eingabe auf europäisches Komma-Format normalisiert

- Neuer Artikel: Textfeld mit Placeholder 4,50 statt Dezimalpunkt
- Artikel bearbeiten: Preise mit Komma anzeigen und akzeptieren
- Backend: Komma vor float()-Konvertierung in Punkt umwandeln

Made-with: Cursor
This commit is contained in:
2026-03-22 17:04:30 +01:00
parent 5c8c4a947e
commit bd4664f23b
2 changed files with 14 additions and 6 deletions

12
app.py
View File

@@ -221,7 +221,11 @@ def admin(instance_id):
if action == "add_product":
name = request.form.get('add_name', '').strip()
price = request.form.get('add_price', type=float)
price_str = request.form.get('add_price', '').replace(',', '.').strip()
try:
price = float(price_str) if price_str else None
except ValueError:
price = None
icon = request.form.get('add_icon', '🛒').strip() or '🛒'
color = request.form.get('add_color', 'btn-primary')
if name and price is not None:
@@ -244,7 +248,11 @@ def admin(instance_id):
for row in products_rows:
pos = row['position']
name = request.form.get(f'name_{pos}')
price = request.form.get(f'price_{pos}', type=float)
price_str = request.form.get(f'price_{pos}', '').replace(',', '.').strip()
try:
price = float(price_str) if price_str else None
except ValueError:
price = None
icon = request.form.get(f'icon_{pos}')
color = request.form.get(f'color_{pos}')
if name is not None and price is not None: