top bar fix
diff --git a/support/doctype/newsletter/newsletter.py b/support/doctype/newsletter/newsletter.py
index 97b4779..536b649 100644
--- a/support/doctype/newsletter/newsletter.py
+++ b/support/doctype/newsletter/newsletter.py
@@ -114,12 +114,14 @@
doctype = doctype, email_field = args["email_field"])
lead_naming_series = None
-def create_lead(email):
+def create_lead(email_id):
"""create a lead if it does not exist"""
+ from email.utils import parseaddr
+ real_name, email_id = parseaddr(email_id)
lead = Document("Lead")
lead.fields["__islocal"] = 1
- lead.lead_name = email
- lead.email_id = email
+ lead.lead_name = real_name or email_id
+ lead.email_id = email_id
lead.status = "Open"
lead.naming_series = lead_naming_series or get_lead_naming_series()
lead.company = webnotes.conn.get_default("company")
diff --git a/website/utils.py b/website/utils.py
index 3498f67..2954556 100644
--- a/website/utils.py
+++ b/website/utils.py
@@ -189,7 +189,7 @@
select * from `tabTop Bar Item`
where parent='Website Settings' and parentfield='top_bar_items'
order by idx asc""", as_dict=1)
-
+
top_items = [d for d in all_top_items if not d['parent_label']]
# attach child items to top bar
@@ -202,7 +202,7 @@
t['child_items'].append(d)
break
- if "products" in [d.url.split(".")[0] for d in top_items]:
+ if top_items and ("products" in [d.url.split(".")[0] for d in top_items]):
# product categories
products = webnotes.conn.sql("""select t1.item_group as label,
concat(t2.page_name, ".html") as url,