Work on IDAA importing
This commit is contained in:
@@ -316,17 +316,17 @@ async def ins_up_person_contact_address_user_data(
|
|||||||
|
|
||||||
if designation := record.get('designation', ''): # This field is mostly empty in IDAA data from Cvent
|
if designation := record.get('designation', ''): # This field is mostly empty in IDAA data from Cvent
|
||||||
if person_data.get('designations'):
|
if person_data.get('designations'):
|
||||||
person_data['designations'] = (str(person_data['designations']) + ' ' + str(designation)).strip() # professional designation
|
person_data['designations'] = (str(person_data['designations']) + ' ' + str(designation)).strip()[:125] # professional designation
|
||||||
else:
|
else:
|
||||||
person_data['designations'] = str(designation) # professional designation
|
person_data['designations'] = str(designation) # professional designation
|
||||||
elif designation := record.get('professional_designations', ''):
|
elif designation := record.get('professional_designations', ''):
|
||||||
if person_data.get('designations'):
|
if person_data.get('designations'):
|
||||||
person_data['designations'] = (str(person_data['designations']) + ' ' + str(designation)).strip() # professional designation
|
person_data['designations'] = (str(person_data['designations']) + ' ' + str(designation)).strip()[:125] # professional designation
|
||||||
else:
|
else:
|
||||||
person_data['designations'] = str(designation) # professional designation
|
person_data['designations'] = str(designation)[:125] # professional designation
|
||||||
|
|
||||||
if birth_date := record.get('date_of_birth'):
|
if birth_date := record.get('date_of_birth'):
|
||||||
person_data['birth_date'] = datetime.datetime.strptime(birth_date, '%d-%b-%Y')
|
person_data['birth_date'] = datetime.datetime.strptime(birth_date, '%d-%b-%Y').date()
|
||||||
|
|
||||||
if gender_name := record.get('gender_non-binary'):
|
if gender_name := record.get('gender_non-binary'):
|
||||||
if gender_name == 'Prefer not to say': person_data['lu_gender_id'] = 1
|
if gender_name == 'Prefer not to say': person_data['lu_gender_id'] = 1
|
||||||
@@ -398,6 +398,9 @@ async def ins_up_person_contact_address_user_data(
|
|||||||
if 'updated_on' in person_data:
|
if 'updated_on' in person_data:
|
||||||
person_data.pop('updated_on') # I don't want to reset the updated date?
|
person_data.pop('updated_on') # I don't want to reset the updated date?
|
||||||
|
|
||||||
|
# person_data.pop('other_json')
|
||||||
|
# person_data.pop('meta_json')
|
||||||
|
|
||||||
if allow_update_person:
|
if allow_update_person:
|
||||||
if person_obj_up_result := sql_update(data=person_data, table_name='person'):
|
if person_obj_up_result := sql_update(data=person_data, table_name='person'):
|
||||||
log.debug(person_obj_up_result)
|
log.debug(person_obj_up_result)
|
||||||
@@ -426,7 +429,7 @@ async def ins_up_person_contact_address_user_data(
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# Process the contact data
|
# Process the contact data
|
||||||
log.debug('Process the contact data')
|
log.info('Process the contact data')
|
||||||
contact_data = {}
|
contact_data = {}
|
||||||
contact_data['email'] = record['email']
|
contact_data['email'] = record['email']
|
||||||
|
|
||||||
@@ -498,7 +501,7 @@ async def ins_up_person_contact_address_user_data(
|
|||||||
continue # Something unexpected may have happened
|
continue # Something unexpected may have happened
|
||||||
|
|
||||||
# Process the contact address data
|
# Process the contact address data
|
||||||
log.debug('Process the contact address data')
|
log.info('Process the contact address data')
|
||||||
address_data = {}
|
address_data = {}
|
||||||
if record['home_address_line_1']:
|
if record['home_address_line_1']:
|
||||||
address_data['line_1'] = record['home_address_line_1']
|
address_data['line_1'] = record['home_address_line_1']
|
||||||
@@ -562,7 +565,7 @@ async def ins_up_person_contact_address_user_data(
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# Process the user data
|
# Process the user data
|
||||||
log.debug('Process the user data')
|
log.info('Process the user data')
|
||||||
user_data = {}
|
user_data = {}
|
||||||
user_data['name'] = full_name # person_data['full_name']
|
user_data['name'] = full_name # person_data['full_name']
|
||||||
user_data['username'] = record['email']
|
user_data['username'] = record['email']
|
||||||
@@ -583,13 +586,13 @@ async def ins_up_person_contact_address_user_data(
|
|||||||
|
|
||||||
log.debug(user_data)
|
log.debug(user_data)
|
||||||
if user_id:
|
if user_id:
|
||||||
# UPDATE existing user record
|
|
||||||
log.info('UPDATE existing user record')
|
log.info('UPDATE existing user record')
|
||||||
user_data['id'] = user_id
|
user_data['id'] = user_id
|
||||||
user_data.pop('enable')
|
user_data.pop('enable')
|
||||||
user_data.pop('email_verified')
|
user_data.pop('email_verified')
|
||||||
user_data.pop('administrator')
|
user_data.pop('administrator')
|
||||||
user_data.pop('notes')
|
user_data.pop('notes')
|
||||||
|
log.debug(user_data)
|
||||||
if allow_update_user:
|
if allow_update_user:
|
||||||
if user_obj_up_result := sql_update(data=user_data, table_name='user'):
|
if user_obj_up_result := sql_update(data=user_data, table_name='user'):
|
||||||
log.debug(user_obj_up_result)
|
log.debug(user_obj_up_result)
|
||||||
|
|||||||
Reference in New Issue
Block a user