add ip_country to contact pojo
This commit is contained in:
@@ -10,21 +10,16 @@ class ContactPojo:
|
|||||||
last_name: str
|
last_name: str
|
||||||
first_name: str
|
first_name: str
|
||||||
mail: str
|
mail: str
|
||||||
ccid: str
|
|
||||||
position: int
|
|
||||||
note: str
|
note: str
|
||||||
|
|
||||||
def __init__(self, phone_number: str, passport_number: str, last_name: str, first_name: str, mail: str,
|
def __init__(self, phone_number: str, passport_number: str, last_name: str, first_name: str, mail: str):
|
||||||
ccid: str = "",
|
|
||||||
position: int = 0):
|
|
||||||
self.phone = str(phone_number).replace(".0", "")
|
self.phone = str(phone_number).replace(".0", "")
|
||||||
self.passport = passport_number
|
self.passport = passport_number
|
||||||
self.last_name = last_name
|
self.last_name = last_name
|
||||||
self.first_name = first_name
|
self.first_name = first_name
|
||||||
self.ccid = ccid
|
|
||||||
self.mail = mail
|
self.mail = mail
|
||||||
self.position = position
|
|
||||||
self.note = ""
|
self.note = ""
|
||||||
|
self.ip_country = "FR"
|
||||||
|
|
||||||
def to_firestore_dict(self):
|
def to_firestore_dict(self):
|
||||||
dest = {
|
dest = {
|
||||||
@@ -33,17 +28,16 @@ class ContactPojo:
|
|||||||
u'last_name': self.last_name,
|
u'last_name': self.last_name,
|
||||||
u'first_name': self.first_name,
|
u'first_name': self.first_name,
|
||||||
u'mail': self.mail,
|
u'mail': self.mail,
|
||||||
u'ccid': self.ccid,
|
u'ip_country': self.ip_country
|
||||||
u'position': self.position
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dest
|
return dest
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_contact_from_error_contact(errorContact: ContactInErrorPojo):
|
def get_contact_from_error_contact(errorContact: ContactInErrorPojo):
|
||||||
return ContactPojo(phone_number=errorContact.phone, mail=errorContact.mail, ccid=errorContact.ccid,
|
return ContactPojo(phone_number=errorContact.phone, mail=errorContact.mail,
|
||||||
last_name=errorContact.last_name, first_name=errorContact.first_name,
|
last_name=errorContact.last_name, first_name=errorContact.first_name,
|
||||||
position=errorContact.position, passport_number=errorContact.passport)
|
passport_number=errorContact.passport)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_firestore_dict(source):
|
def from_firestore_dict(source):
|
||||||
@@ -54,6 +48,6 @@ class ContactPojo:
|
|||||||
email = source['mail']
|
email = source['mail']
|
||||||
last_name = source['last_name']
|
last_name = source['last_name']
|
||||||
first_name = source['first_name']
|
first_name = source['first_name']
|
||||||
result = ContactPojo(ccid=ccid, phone_number=phone, passport_number=passport, position=position, mail=email,
|
result = ContactPojo(phone_number=phone, passport_number=passport, mail=email,
|
||||||
last_name=last_name, first_name=first_name)
|
last_name=last_name, first_name=first_name)
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import pandas as pandas
|
|||||||
import validators as validators
|
import validators as validators
|
||||||
import xlsxwriter
|
import xlsxwriter
|
||||||
|
|
||||||
from src.config import CONTACT_LIST_FILE
|
|
||||||
from src.db.mongo_manager import MONGO_STORE_MANAGER
|
from src.db.mongo_manager import MONGO_STORE_MANAGER
|
||||||
from src.pojo.contact_pojo import ContactPojo
|
from src.pojo.contact_pojo import ContactPojo
|
||||||
from src.pojo.mail.mail_pojo import MailAddress
|
from src.pojo.mail.mail_pojo import MailAddress
|
||||||
@@ -29,7 +28,7 @@ def read_links_to_click(file_path):
|
|||||||
print("error on link " + link)
|
print("error on link " + link)
|
||||||
|
|
||||||
|
|
||||||
def read_contacts(file_name=CONTACT_LIST_FILE) -> list:
|
def read_contacts(file_name) -> list:
|
||||||
print("read file " + file_name)
|
print("read file " + file_name)
|
||||||
contact_list_in_json = pandas.read_excel(file_name).to_json(orient='records')
|
contact_list_in_json = pandas.read_excel(file_name).to_json(orient='records')
|
||||||
contact_dict_list = json.loads(contact_list_in_json)
|
contact_dict_list = json.loads(contact_list_in_json)
|
||||||
@@ -43,12 +42,16 @@ def read_contacts(file_name=CONTACT_LIST_FILE) -> list:
|
|||||||
first_name = name[-1]
|
first_name = name[-1]
|
||||||
else:
|
else:
|
||||||
first_name = ''.join(name[1:len(name)])
|
first_name = ''.join(name[1:len(name)])
|
||||||
|
ip_country = "FR"
|
||||||
|
if contact_dict.get('ip_country') is not None:
|
||||||
|
ip_country = contact_dict['ip_country']
|
||||||
|
|
||||||
contact = ContactPojo(phone_number=contact_dict['phone'],
|
contact = ContactPojo(phone_number=contact_dict['phone'],
|
||||||
last_name=last_name,
|
last_name=last_name,
|
||||||
first_name=first_name,
|
first_name=first_name,
|
||||||
passport_number=contact_dict['passport'],
|
passport_number=contact_dict['passport'],
|
||||||
mail=contact_dict['email'])
|
mail=contact_dict['email'])
|
||||||
|
contact.ip_country = ip_country
|
||||||
contact_list.append(contact)
|
contact_list.append(contact)
|
||||||
return contact_list
|
return contact_list
|
||||||
|
|
||||||
@@ -72,7 +75,7 @@ class ExcelHelper:
|
|||||||
user_agent_list.append(user_agent_dict['user_agent'])
|
user_agent_list.append(user_agent_dict['user_agent'])
|
||||||
print(user_agent_list)
|
print(user_agent_list)
|
||||||
|
|
||||||
def check_contact_list(self, file_name=CONTACT_LIST_FILE):
|
def check_contact_list(self, file_name):
|
||||||
contact_list = read_contacts(file_name)
|
contact_list = read_contacts(file_name)
|
||||||
for contact in contact_list:
|
for contact in contact_list:
|
||||||
if contact.first_name is None or len(contact.first_name) == 0:
|
if contact.first_name is None or len(contact.first_name) == 0:
|
||||||
@@ -99,7 +102,7 @@ class ExcelHelper:
|
|||||||
contact_list.append(contact)
|
contact_list.append(contact)
|
||||||
return contact_list
|
return contact_list
|
||||||
|
|
||||||
def read_names(self, file_name=CONTACT_LIST_FILE) -> list:
|
def read_names(self, file_name) -> list:
|
||||||
contact_list_in_json = pandas.read_excel(file_name).to_json(orient='records')
|
contact_list_in_json = pandas.read_excel(file_name).to_json(orient='records')
|
||||||
contact_dict_list = json.loads(contact_list_in_json)
|
contact_dict_list = json.loads(contact_list_in_json)
|
||||||
contact_list = []
|
contact_list = []
|
||||||
@@ -134,7 +137,7 @@ class ExcelHelper:
|
|||||||
|
|
||||||
return contact_list
|
return contact_list
|
||||||
|
|
||||||
def read_email_pojo(self, file_name=CONTACT_LIST_FILE) -> list:
|
def read_email_pojo(self, file_name) -> list:
|
||||||
email_info_in_json = pandas.read_excel(file_name).to_json(orient='records')
|
email_info_in_json = pandas.read_excel(file_name).to_json(orient='records')
|
||||||
contact_dict_list = json.loads(email_info_in_json)
|
contact_dict_list = json.loads(email_info_in_json)
|
||||||
contact_list = []
|
contact_list = []
|
||||||
|
|||||||
Reference in New Issue
Block a user