def _att_as_dict(self, attendees):
     ''' Given a list of brains, we return proper dictionaries '''
     voc = self.vocabs
     atts = []
     for brain in attendees:
         att = {}
         att['id'] = brain.getId
         att['reg'] = brain.getPath().split('/')[-2]
         att['reg_url'] = '/'.join(brain.getURL().split('/')[:-1])
         att['url'] = brain.getURL()
         att['date'] = DateTime(brain.created).strftime('%Y-%m-%d %H:%M')
         att['fullname'] = brain.Title
         att_type = voc['types'].getTerm(
             brain.Subject[0]).title if brain.Subject else ''
         att['type'] = att_type
         att['email'] = brain.email
         caipirinha = brain.caipirinha
         if caipirinha.startswith('yes'):
             caipirinha = int(caipirinha[-1])
         else:
             caipirinha = 0
         att['caipirinha'] = caipirinha
         att['wall'] = brain.wall
         att['badge_name'] = brain.badge_name or att['fullname']
         att['gender'] = voc['gender'].getTerm(brain.gender).title
         att['t_shirt_size'] = voc['tshirt'].getTerm(
             brain.t_shirt_size).title
         att['state'] = REVIEW_STATE.get(brain.review_state,
                                         brain.review_state)
         atts.append(att)
     return atts
 def _regs_as_dict(self, registrations):
     ''' Given a list of brains, we return proper dictionaries '''
     voc = self.vocabs
     att_by_reg = self.attendees_by_registration()
     regs = []
     for brain in registrations:
         reg = {}
         reg['id'] = brain.getId
         reg['url'] = brain.getURL()
         reg['email'] = brain.email
         reg['date'] = DateTime(brain.created).strftime('%Y-%m-%d %H:%M')
         reg['title'] = brain.Title
         reg['type'] = voc['types'].getTerm(brain.Subject[0]).title
         reg['num_attendees'] = brain.num_attendees
         reg['price_est'] = fmt_price(brain.price_est)
         reg['amount'] = fmt_price(brain.amount)
         attendees = att_by_reg.get(brain.getId, [])
         caipirinha = sum([int(att['caipirinha']) for att in attendees])
         reg['caipirinha'] = caipirinha
         wall = sum([int(att['wall'])
                     for att in attendees
                     if att['wall'].isdigit()])
         reg['wall'] = wall
         reg['state'] = REVIEW_STATE.get(brain.review_state,
                                         brain.review_state)
         regs.append(reg)
     return regs
 def _att_as_dict(self, attendees):
     ''' Given a list of brains, we return proper dictionaries '''
     voc = self.vocabs
     atts = []
     for brain in attendees:
         reg_type = raw_type = ''
         if brain.Subject:
             reg_type = brain.Subject[0]
             raw_type = reg_type
             if reg_type == 'speaker_c':
                 reg_type = u'Palestrante'
             elif reg_type == 'organizer':
                 reg_type = u'Organização'
             else:
                 reg_type = u'Participante'
         att = {}
         att['id'] = brain.getId
         att['uid'] = brain.UID
         att['reg'] = brain.getPath().split('/')[-2]
         att['reg_url'] = '/'.join(brain.getURL().split('/')[:-1])
         att['url'] = brain.getURL()
         att['date'] = DateTime(brain.created).strftime('%Y-%m-%d %H:%M')
         att['fullname'] = brain.Title
         att['type'] = reg_type
         att['raw_type'] = raw_type
         att['email'] = brain.email
         att['badge_name'] = brain.badge_name or att['fullname']
         att['gender'] = voc['gender'].getTerm(brain.gender).title
         att['t_shirt_size'] = voc['tshirt'].getTerm(
             brain.t_shirt_size).title
         att['rev_state'] = REVIEW_STATE.get(brain.review_state,
                                             brain.review_state)
         att['organization'] = brain.organization
         att['lat'] = brain.latitude
         att['long'] = brain.longitude
         att['city'] = brain.city
         att['state'] = brain.state
         att['country'] = brain.country
         atts.append(att)
     return atts