diff --git a/app.py b/app.py index 2e90be5..2694481 100644 --- a/app.py +++ b/app.py @@ -16,19 +16,19 @@ def view_customer(index): if not customer_data: return "No customer data provided.", 400 - # 确保index在合法范围内 + # 确保 index 在合法范围内 if index < 0 or index >= len(customer_data): return "Index out of range.", 400 customer = customer_data[index] - # 为每个 email_addresses 列表中的项添加唯一的索引 + # 为每个 email addresses 列表中的项添加唯一的索引 for domain, info in customer.items(): print(f"..........domain={domain}") print(f"..........info={info}") - if 'email_addresses' in info and isinstance(info['email_addresses'], list): - for email_idx, email in enumerate(info['email_addresses']): - email['idx'] = email_idx # 给每个email项添加唯一的索引 + if 'email addresses' in info and isinstance(info['email addresses'], list): + for email_idx, email in enumerate(info['email addresses']): + email['idx'] = email_idx # 给每个 email 项添加唯一的索引 is_first = index == 0 is_last = index == len(customer_data) - 1 @@ -49,15 +49,15 @@ def update_customers(index): for domain, info in customer.items(): print(f"..........domain={domain}") print(f"..........info={info}") - if 'customer_industry' in info: - info['customer_industry'] = updated_data.get(f'{domain}_industry', [info['customer_industry']])[0] + if 'customer industry' in info: + info['customer industry'] = updated_data.get(f'{domain}_industry', [info['customer industry']])[0] - if 'email_addresses' in info and isinstance(info['email_addresses'], list): - for j, email in enumerate(info['email_addresses']): - email['owner_name'] = updated_data.get(f'{domain}_owner_name_{j}', [email['owner_name']])[0] - email['email_address'] = updated_data.get(f'{domain}_email_address_{j}', [email['email_address']])[0] + if 'email addresses' in info and isinstance(info['email addresses'], list): + for j, email in enumerate(info['email addresses']): + email["owner's name"] = updated_data.get(f'{domain}_owner_name_{j}', [email["owner's name"]])[0] + email['email address'] = updated_data.get(f'{domain}_email_address_{j}', [email['email address']])[0] email['category'] = updated_data.get(f'{domain}_category_{j}', [email['category']])[0] - email['promotion_history'] = updated_data.get(f'{domain}_promotion_history_{j}', [', '.join(email['promotion_history'])])[0].split(', ') + email['promotion history'] = updated_data.get(f'{domain}_promotion_history_{j}', [', '.join(email['promotion history'])])[0].split(', ') return redirect(url_for('view_customer', index=index)) diff --git a/templates/edit_customers.html b/templates/edit_customers.html index 0a1cd19..294c7e9 100644 --- a/templates/edit_customers.html +++ b/templates/edit_customers.html @@ -11,17 +11,17 @@
{% for domain, info in customer.items() %}

Domain: {{ domain }}

-

Customer Industry:

+

Customer Industry:

Email Addresses

- {% if info.get('email_addresses') %} - {% for email in info['email_addresses'] %} + {% if info.get('email addresses') %} + {% for email in info['email addresses'] %}
-

Owner Name:

-

Email Address:

+

Owner Name:

+

Email Address:

Category:

-

Promotion History:

+

Promotion History:

{% endfor %} {% else %}