This commit is contained in:
parent
e5df9bd9fd
commit
2b2451ec6f
24
app.py
24
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))
|
||||
|
||||
|
|
|
|||
|
|
@ -11,17 +11,17 @@
|
|||
<form method="POST" action="/update/{{ index }}">
|
||||
{% for domain, info in customer.items() %}
|
||||
<h3>Domain: {{ domain }}</h3>
|
||||
<p>Customer Industry: <input type="text" name="{{ domain }}_industry" value="{{ info.get('customer_industry', '') }}"></p>
|
||||
<p>Customer Industry: <input type="text" name="{{ domain }}_industry" value="{{ info.get('customer industry', '') }}"></p>
|
||||
|
||||
<h4>Email Addresses</h4>
|
||||
<div>
|
||||
{% if info.get('email_addresses') %}
|
||||
{% for email in info['email_addresses'] %}
|
||||
{% if info.get('email addresses') %}
|
||||
{% for email in info['email addresses'] %}
|
||||
<div>
|
||||
<p>Owner Name: <input type="text" name="{{ domain }}_owner_name_{{ email['idx'] }}" value="{{ email.get('owner_name', '') }}"></p>
|
||||
<p>Email Address: <input type="text" name="{{ domain }}_email_address_{{ email['idx'] }}" value="{{ email.get('email_address', '') }}"></p>
|
||||
<p>Owner Name: <input type="text" name="{{ domain }}_owner_name_{{ email['idx'] }}" value="{{ email.get("owner's name", '') }}"></p>
|
||||
<p>Email Address: <input type="text" name="{{ domain }}_email_address_{{ email['idx'] }}" value="{{ email.get('email address', '') }}"></p>
|
||||
<p>Category: <input type="text" name="{{ domain }}_category_{{ email['idx'] }}" value="{{ email.get('category', '') }}"></p>
|
||||
<p>Promotion History: <input type="text" name="{{ domain }}_promotion_history_{{ email['idx'] }}" value="{{ email.get('promotion_history', []) | join(', ') }}"></p>
|
||||
<p>Promotion History: <input type="text" name="{{ domain }}_promotion_history_{{ email['idx'] }}" value="{{ email.get('promotion history', []) | join(', ') }}"></p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
|
|
|
|||
Loading…
Reference in New Issue