Ansprechpartner-Felder für Willkommensseite mit Markdown-Support
This commit is contained in:
27
app.py
27
app.py
@@ -685,6 +685,7 @@ def add_customer():
|
||||
success = None
|
||||
logo_urls = [None, None, None]
|
||||
customer_names = ["", "", ""]
|
||||
contacts = ["", "", ""]
|
||||
site = request.args.get("site") or request.form.get("site") or ""
|
||||
|
||||
# Fallback auf ersten für den User zugänglichen Standort
|
||||
@@ -703,6 +704,11 @@ def add_customer():
|
||||
request.form.get("customer_name_2", "").strip(),
|
||||
request.form.get("customer_name_3", "").strip(),
|
||||
]
|
||||
contacts = [
|
||||
request.form.get("contact_1", "").strip(),
|
||||
request.form.get("contact_2", "").strip(),
|
||||
request.form.get("contact_3", "").strip(),
|
||||
]
|
||||
filled_names = [n for n in customer_names if n]
|
||||
|
||||
print(f"🔍 APP.PY - Suche nach Kunden: {filled_names} (site: {site})")
|
||||
@@ -725,6 +731,14 @@ def add_customer():
|
||||
else:
|
||||
valid_names = [n for n, l in valid]
|
||||
valid_urls = [l for n, l in valid]
|
||||
valid_contacts = []
|
||||
for name in valid_names:
|
||||
for i, cn in enumerate(customer_names):
|
||||
if cn == name:
|
||||
valid_contacts.append(contacts[i] if i < len(contacts) else "")
|
||||
break
|
||||
else:
|
||||
valid_contacts.append("")
|
||||
for i, name in enumerate(customer_names):
|
||||
for j, (vn, vu) in enumerate(zip(valid_names, valid_urls)):
|
||||
if vn == name:
|
||||
@@ -732,14 +746,14 @@ def add_customer():
|
||||
break
|
||||
|
||||
bg_url = get_background_url(site)
|
||||
html_filename = generate_welcome_page.save_welcome_page(valid_names, valid_urls, site=site, background_url=bg_url)
|
||||
html_filename = generate_welcome_page.save_welcome_page(valid_names, valid_urls, contacts=valid_contacts, site=site, background_url=bg_url)
|
||||
|
||||
if html_filename:
|
||||
if generate_welcome_page.add_customer_to_lobby_playlist(html_filename, site=site):
|
||||
# Letzte Kundendaten für Background-Update speichern
|
||||
config = load_config()
|
||||
site_cfg = config.setdefault("sites", {}).setdefault(site, {})
|
||||
site_cfg["welcome_data"] = {"names": valid_names, "logo_urls": valid_urls}
|
||||
site_cfg["welcome_data"] = {"names": valid_names, "logo_urls": valid_urls, "contacts": valid_contacts}
|
||||
save_config(config)
|
||||
add_history_entry("customer_added", f"Kunden ({', '.join(valid_names)}) zur Willkommensseite an Standort '{site}' hinzugefügt", current_user.email)
|
||||
success = f"✅ Willkommensseite mit {len(valid_names)} Kunden erstellt!"
|
||||
@@ -755,12 +769,17 @@ def add_customer():
|
||||
config = load_config()
|
||||
site_list = get_site_list(config)
|
||||
background_url = get_background_url(site)
|
||||
welcome_data = config.get("sites", {}).get(site, {}).get("welcome_data", {})
|
||||
saved_contacts = welcome_data.get("contacts", ["", "", ""])
|
||||
if not contacts:
|
||||
contacts = saved_contacts
|
||||
return render_template(
|
||||
"customer.html",
|
||||
error=error,
|
||||
success=success,
|
||||
logo_urls=logo_urls,
|
||||
customer_names=customer_names,
|
||||
contacts=contacts,
|
||||
site=site,
|
||||
site_list=site_list,
|
||||
current_site=site,
|
||||
@@ -804,7 +823,9 @@ def api_add_customer():
|
||||
if not logo_url:
|
||||
return jsonify({"error": "Logo not found"}), 400
|
||||
|
||||
html_filename = generate_welcome_page.save_welcome_page(customer_name, logo_url, site=site)
|
||||
contact = data.get("contact", "").strip()
|
||||
|
||||
html_filename = generate_welcome_page.save_welcome_page([customer_name], [logo_url], contacts=[contact], site=site)
|
||||
|
||||
if not html_filename:
|
||||
return jsonify({"error": "Failed to create welcome page"}), 500
|
||||
|
||||
Reference in New Issue
Block a user