Example #1
0
 def _bulk_create(self, tuples):
     with self.django_klass.delayed as d:
         for t in tuples:
             payload = dict(hashcode=Registrant.calc_hashcode(t[0]['email']), event_id=self.event.id, created_at=self.now.us, updated_at=self.now.us, **t[0])
             if payload.get('started_at',None): payload['started_at'] = int(payload['started_at'])
             if payload.get('stopped_at',None): payload['stopped_at'] = int(payload['stopped_at'])
             d.insert(payload)
     from django.db import transaction
     transaction.commit_unless_managed()
     registrant_map = dict((r.email,r) for r in self.django_klass.objects.filter(event = self.event))
     return [(tuples[i][0]['email'] in registrant_map and registrant_map[tuples[i][0]['email']] or None, tuples[i][0], tuples[i][1]) for i in xrange(len(tuples))]
Example #2
0
 def _single_create(self, dobj):
     dobj = dobj.copy()
     dobj['hashcode'] = Registrant.calc_hashcode(dobj['email'])
     dobj['event'] = self.event
     return super(RegistrantDjangoStore, self)._single_create(dobj)