-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
35 lines (29 loc) · 1.3 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from contact import Contact
def match_and_add_contact(contacts, leads, registrant):
# Try to match registrant's email to our list of contacts
for contact in contacts:
if contact.email == registrant['email'] and contact.email != None:
contact.update(registrant)
return contacts, leads
# Try to match registrant's phone to our contacts
for contact in contacts:
if contact.phone == registrant['phone'] and contact.phone != None:
contact.update(registrant)
return contacts, leads
# Try to match leads with email
for lead in leads:
if lead.email == registrant['email'] and lead.email != None:
lead.update(registrant)
contacts.append(Contact(lead.name, lead.email, lead.phone))
leads.remove(lead)
return contacts, leads
# Try to match leads with phone
for lead in leads:
if lead.phone == registrant['phone'] and lead.phone != None:
lead.update(registrant)
contacts.append(Contact(lead.name, lead.email, lead.phone))
leads.remove(lead)
return contacts, leads
# If no match is found, add to contacts
contacts.append(Contact(registrant['name'], registrant['email'], registrant['phone']))
return contacts, leads