def _getAnswer(self): event_persons = [] criteria = { 'surName': self._surName, 'name': self._name, 'organisation': self._organisation, 'email': self._email } users = search_avatars(criteria, self._exactMatch, self._searchExt) if self._event: fields = { EventPerson.first_name: self._name, EventPerson.last_name: self._surName, EventPerson.email: self._email, EventPerson.affiliation: self._organisation } criteria = [ unaccent_match(col, val, exact=self._exactMatch) for col, val in fields.iteritems() ] event_persons = self._event.persons.filter(*criteria).all() fossilized_users = fossilize( sorted(users, key=lambda av: (av.getStraightFullName(), av.getEmail()))) fossilized_event_persons = map(serialize_event_person, event_persons) unique_users = { to_unicode(user['email']): user for user in chain(fossilized_users, fossilized_event_persons) } return sorted(unique_users.values(), key=lambda x: (to_unicode(x['name']).lower(), to_unicode(x['email'])))
def _getAnswer(self): event_persons = [] criteria = { 'surName': self._surName, 'name': self._name, 'organisation': self._organisation, 'email': self._email } users = search_avatars(criteria, self._exactMatch, self._searchExt) if self._event: fields = {EventPerson.first_name: self._name, EventPerson.last_name: self._surName, EventPerson.email: self._email, EventPerson.affiliation: self._organisation} criteria = [unaccent_match(col, val, exact=self._exactMatch) for col, val in fields.iteritems()] event_persons = self._event.persons.filter(*criteria).all() fossilized_users = fossilize(sorted(users, key=lambda av: (av.getStraightFullName(), av.getEmail()))) fossilized_event_persons = map(serialize_event_person, event_persons) unique_users = {to_unicode(user['email']): user for user in chain(fossilized_users, fossilized_event_persons)} return sorted(unique_users.values(), key=lambda x: (to_unicode(x['name']).lower(), to_unicode(x['email'])))
def _getAnswer(self): event_persons = [] event_abstract_submitters = [] criteria = { 'surName': self._surName, 'name': self._name, 'organisation': self._organisation, 'email': self._email, 'abstract': self._abstract, 'track': self._track } users = search_avatars(criteria, self._exactMatch, self._searchExt) users2 = users if self._event: fields = { EventPerson.first_name: self._name, EventPerson.last_name: self._surName, EventPerson.email: self._email, EventPerson.affiliation: self._organisation } criteria = [ unaccent_match(col, val, exact=self._exactMatch) for col, val in fields.iteritems() ] if not self._abstract: if not self._track: event_persons = self._event.persons.filter(*criteria).all() event_abstract_submitters = event_persons else: event_abstract_submitters = EventPerson.query.join( Abstract, (Abstract.submitter_id == EventPerson.user_id) & (Abstract.event_id == self._event.id)).join( Track, (Abstract.accepted_track_id == Track.id)).with_entities( EventPerson.id, Abstract.title.label('abstract'), Track.title.label('track'), EventPerson.email, EventPerson.last_name.label('full_name'), EventPerson.first_name, EventPerson.last_name, EventPerson.title.label('title'), EventPerson.affiliation, EventPerson.phone, EventPerson.address, EventPerson.user_id).filter( Track.title.op("~*")( r'[[:<:]]{}[[:>:]]'.format( self._track))).filter( *criteria).all() elif not self._track: event_abstract_submitters = EventPerson.query.join( Abstract, (Abstract.submitter_id == EventPerson.user_id) & (Abstract.event_id == self._event.id)).with_entities( EventPerson.id, Abstract.title.label('abstract'), EventPerson.email, EventPerson.last_name.label('full_name'), EventPerson.first_name, EventPerson.last_name, EventPerson.title.label('title'), EventPerson.affiliation, EventPerson.phone, EventPerson.address, EventPerson.user_id).filter( unaccent_match( Abstract.title, self._abstract, self._exactMatch)).filter(*criteria).all() else: event_abstract_submitters = EventPerson.query.join( Abstract, (Abstract.submitter_id == EventPerson.user_id) & (Abstract.event_id == self._event.id)).join( Track, (Abstract.accepted_track_id == Track.id)).with_entities( EventPerson.id, Abstract.title.label('abstract'), Track.title.label('track'), EventPerson.email, EventPerson.last_name.label('full_name'), EventPerson.first_name, EventPerson.last_name, EventPerson.title.label('title'), EventPerson.affiliation, EventPerson.phone, EventPerson.address, EventPerson.user_id).filter( unaccent_match( Abstract.title, self._abstract, self._exactMatch)).filter( Track.title.op("~*")( r'[[:<:]]{}[[:>:]]'.format( self._track))).filter( *criteria).all() fossilized_users = fossilize( sorted(users, key=lambda av: (av.getStraightFullName(), av.getEmail()))) fossilized_abstract_submitters = map(serialize_event_person, event_abstract_submitters) for submitter in fossilized_abstract_submitters: for event_submitter in event_abstract_submitters: if (self._abstract or self._track) and submitter['id'] == event_submitter[0]: submitter['abstract'] = event_submitter[1] if self._track: submitter['track'] = event_submitter[2] for usre in fossilized_users: for usre2 in users2: if hasattr(usre2.user, 'abstract' ): #and int(usre['id']) == int(usre2.user.id): usre['abstract'] = usre2.user.abstract usre['track'] = usre2.user.track if self._eventPerson: unique_users = { to_unicode(user['email']): user for user in fossilized_abstract_submitters } else: unique_users = { to_unicode(user['email']): user for user in chain(fossilized_users, fossilized_abstract_submitters) } return sorted(unique_users.values(), key=lambda x: (to_unicode(x['name']).lower(), to_unicode(x['email'])))