improve import via Eventbrite API

This commit is contained in:
Davide Alberani 2017-09-16 18:36:35 +02:00
parent 253701e159
commit 5e0d2aa933
2 changed files with 19 additions and 2 deletions

View file

@ -12,7 +12,7 @@ Now go to the Eventbrite web page of your event, and copy the "eid" field of the
In the EventMan "Import tickets" page, set the copied OAuth token and Event ID; it's also possible to select an existing event that will receive the new attendees, or create a brand new event with the information from Eventbrite.
If you've created a new event, don't forget to edit it to add a registration form so that it will contain at least "name", "surname", "email".
If you've created a new event, don't forget to edit it to add a registration form so that it will contain at least "name", "surname", "email" (also adding "company" and "job title" is a good idea).
## CSV import

View file

@ -151,6 +151,8 @@ def reworkObj(obj, kind='event'):
obj[new] = transf(obj[old])
if old != new:
del obj[old]
if 'id' in obj:
del obj['id']
if kind == 'event':
if 'name' in obj:
obj['title'] = obj.get('name', {}).get('text') or ''
@ -168,17 +170,32 @@ def reworkObj(obj, kind='event'):
obj['name'] = profile.get('first_name') or ''
if not (obj['surname'] and obj['name']):
obj['surname'] = complete_name
obj['email'] = profile.get('email') or ''
for key in 'name', 'first_name', 'last_name':
if key in profile:
del profile[key]
obj.update(profile)
if 'profile' in obj:
del obj['profile']
obj['email'] = obj.get('email') or ''
if 'job_title' in obj:
obj['job title'] = obj['job_title']
del obj['job_title']
if 'costs' in obj:
del obj['costs']
return obj
def expandBarcodes(attendees):
"""Generate an attendee for each barcode in the Eventbrite API data."""
for attendee in attendees:
if 'id' in attendee:
del attendee['id']
barcodes = attendee.get('barcodes') or []
if not barcodes:
yield attendee
barcodes = [b.get('barcode') for b in barcodes if b.get('barcode')]
if 'barcodes' in attendee:
del attendee['barcodes']
for code in barcodes:
att_copy = copy.deepcopy(attendee)
att_copy['order_nr'] = code