Commits

Anonymous committed 41fdfdc

Added venues

Comments (0)

Files changed (3)

eventbrite/admin.py

     )
 admin.site.register(models.Ticket, EventbriteTicketAdmin)
 
+
 class EventbriteAttendeeAdmin(admin.ModelAdmin):
     list_display = (
         'id',
     )
 admin.site.register(models.Attendee, EventbriteAttendeeAdmin)
 
+
 class EventbriteContactAdmin(admin.ModelAdmin):
     list_display = (
         'first_name',
         'email',
     )
 admin.site.register(models.Contact, EventbriteContactAdmin)
+
+
+class EventbriteVenueAdmin(admin.ModelAdmin):
+    list_display = (
+        'name',
+        'address',
+    )
+admin.site.register(models.Venue, EventbriteVenueAdmin)

eventbrite/models.py

     title = models.CharField(max_length=30, blank=False)
     url = models.URLField(blank=False)
     tags = models.CharField(max_length=30, blank=True)
-    
+    venue = models.ForeignKey('Venue', null=True)
     def __unicode__(self):
         return self.title
     
     
     def __unicode__(self):
         return '%s %s' % (self.first_name, self.last_name)
+        
+        
+class Venue(models.Model):
+    id = models.PositiveIntegerField(primary_key=True)
+    name = models.CharField(max_length=30)
+    address = models.CharField(max_length=30)
+    address_2 = models.CharField(max_length=30)
+    city = models.CharField(max_length=15)
+    region = models.CharField(max_length=20)
+    postal_code = models.PositiveIntegerField()
+    country = models.CharField(max_length=30)
+    country_code = models.CharField(max_length=5)
+    longitude = models.FloatField(blank=False)
+    latitude =  models.FloatField(blank=False)
+    

eventbrite/utils.py

-from eventbrite.models import Event, Ticket, Attendee, Contact
+from eventbrite.models import Event, Ticket, Attendee, Contact, Venue
 from eventbrite import API
 
 api = API()
     events = api.call('user_list_events',)['events']
     for event in events:
         event = event['event']
+        if 'venue' in event:
+            del event['venue']['Lat-Long']
+            v = Venue(
+                **(event['venue'])
+            )
+            v.save()
         e = Event(
             **dict(
                 (k, v) for k, v in event.iteritems() \
                 'start_date', 'end_date', 'status', 'timezone', 'url', 'tags'])
             ) 
         )
+        if 'venue' in event:
+            e.venue = v
         e.save()
         attendee_flag = False
         if 'tickets' in event:
                     last_name = attendee['last_name'],
                 )
                 c.save()
-                del attendee['email']
-                del attendee['first_name']
-                del attendee['last_name']
-                del attendee['ticket_id']
                 if not attendee['event_date']:
                     del attendee['event_date']
-                a = Attendee(ticket_id=attendee_ticket, contact=c, **attendee)
+                a = Attendee(ticket_id=attendee_ticket, contact=c,
+                    **dict(
+                        (k, v) for k, v in attendee.iteritems() \
+                        if k in set([
+                            'amount_paid', 'barcode', 'created', 'currency',
+                            'discount', 'event_date', 'id', 'modified',
+                            'order_id', 'order_type', 'quantity', 'affiliate',
+                            'contact'
+                        ])
+                    )
+                )
                 a.save()