Browse Source

improve import via Eventbrite API

Davide Alberani 6 years ago
parent
commit
5e0d2aa933
2 changed files with 19 additions and 2 deletions
  1. 1 1
      docs/Eventbrite_import.md
  2. 18 1
      utils.py

+ 1 - 1
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.
 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
 ## CSV import

+ 18 - 1
utils.py

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