diff --git a/docs/Eventbrite_import.md b/docs/Eventbrite_import.md index ec567ae..cd153a8 100644 --- a/docs/Eventbrite_import.md +++ b/docs/Eventbrite_import.md @@ -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 diff --git a/utils.py b/utils.py index 05d3e23..ac063f2 100644 --- a/utils.py +++ b/utils.py @@ -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