import: map marketing consent CSV column to event_badge.agree_to_tc and allow_tracking
This commit is contained in:
@@ -656,6 +656,44 @@ async def event_id_badge_import_zoom_csv(
|
|||||||
if badge_type_code:
|
if badge_type_code:
|
||||||
log.info(f"Axonius mapping applied: '{ticket_name}' -> '{badge_type_code}'")
|
log.info(f"Axonius mapping applied: '{ticket_name}' -> '{badge_type_code}'")
|
||||||
|
|
||||||
|
# Parse marketing consent column (if present) and map to badge fields.
|
||||||
|
# Expected values: "Opt-in" => agree_to_tc=True, allow_tracking=True
|
||||||
|
# "Opt-out" => agree_to_tc=False, allow_tracking=False
|
||||||
|
# "N/A" => None/NULL
|
||||||
|
marketing_raw = None
|
||||||
|
for _k in ('Agree to receive marketing communication?', 'Agree to receive marketing communication', 'Agree to TC', 'agree_to_tc'):
|
||||||
|
if _k in record and str(record.get(_k)).strip() != '':
|
||||||
|
marketing_raw = str(record.get(_k)).strip()
|
||||||
|
break
|
||||||
|
|
||||||
|
agree_to_tc_val = None
|
||||||
|
allow_tracking_val = None
|
||||||
|
if marketing_raw is not None:
|
||||||
|
m = marketing_raw.strip()
|
||||||
|
m_low = m.lower()
|
||||||
|
if m_low in ('n/a', 'na'):
|
||||||
|
agree_to_tc_val = None
|
||||||
|
allow_tracking_val = None
|
||||||
|
elif m_low in ('opt-in', 'optin', 'opt in'):
|
||||||
|
agree_to_tc_val = True
|
||||||
|
allow_tracking_val = True
|
||||||
|
elif m_low in ('opt-out', 'optout', 'opt out'):
|
||||||
|
agree_to_tc_val = False
|
||||||
|
allow_tracking_val = False
|
||||||
|
else:
|
||||||
|
if m_low in ('yes', 'y', 'true', '1'):
|
||||||
|
agree_to_tc_val = True
|
||||||
|
allow_tracking_val = True
|
||||||
|
elif m_low in ('no', 'n', 'false', '0'):
|
||||||
|
agree_to_tc_val = False
|
||||||
|
allow_tracking_val = False
|
||||||
|
else:
|
||||||
|
agree_to_tc_val = None
|
||||||
|
allow_tracking_val = None
|
||||||
|
|
||||||
|
# Need to deal with this special field/column for Axonius
|
||||||
|
# "Agree to receive marketing communication?"
|
||||||
|
|
||||||
event_person_data = {
|
event_person_data = {
|
||||||
'account_id': account_id,
|
'account_id': account_id,
|
||||||
'event_id': event_id,
|
'event_id': event_id,
|
||||||
@@ -712,6 +750,8 @@ async def event_id_badge_import_zoom_csv(
|
|||||||
'event_badge_template_id_random': 'RKYp2HcQm9o',
|
'event_badge_template_id_random': 'RKYp2HcQm9o',
|
||||||
'badge_type': ticket_name,
|
'badge_type': ticket_name,
|
||||||
'badge_type_code': badge_type_code,
|
'badge_type_code': badge_type_code,
|
||||||
|
'agree_to_tc': agree_to_tc_val,
|
||||||
|
'allow_tracking': allow_tracking_val,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user