Ejemplo n.º 1
0
def test_get_registered_event_persons(dummy_event, dummy_user, dummy_regform):
    create_registration(dummy_regform, {
        'email': '*****@*****.**',
        'first_name': 'John',
        'last_name': 'Doe',
    },
                        notify_user=False)

    user_person = EventPerson.create_from_user(dummy_user, dummy_event)
    no_user_person = EventPerson(email='*****@*****.**',
                                 first_name='John',
                                 last_name='Doe')

    create_registration(dummy_regform, {
        'email': '*****@*****.**',
        'first_name': 'Jane',
        'last_name': 'Doe',
    },
                        notify_user=False)

    no_user_no_reg = EventPerson(email='*****@*****.**',
                                 first_name='No',
                                 last_name='Show')
    dummy_event.persons.append(user_person)
    dummy_event.persons.append(no_user_person)
    dummy_event.persons.append(no_user_no_reg)
    db.session.flush()

    registered_persons = get_registered_event_persons(dummy_event)
    assert registered_persons == {user_person, no_user_person}
Ejemplo n.º 2
0
    def _process(self):
        contribution_persons = (ContributionPersonLink.find(
            ContributionPersonLink.contribution.has(
                self._membership_filter)).all())
        contribution_persons.extend(
            SubContributionPersonLink.find(
                SubContributionPersonLink.subcontribution.has(
                    SubContribution.contribution.has(
                        self._membership_filter))).all())

        registered_persons = get_registered_event_persons(self.event)

        contribution_persons_dict = defaultdict(
            lambda: {
                'speaker': False,
                'primary_author': False,
                'secondary_author': False,
                'not_registered': True
            })
        for contrib_person in contribution_persons:
            person_roles = contribution_persons_dict[contrib_person.person]
            person_roles['speaker'] |= contrib_person.is_speaker
            person_roles[
                'primary_author'] |= contrib_person.author_type == AuthorType.primary
            person_roles[
                'secondary_author'] |= contrib_person.author_type == AuthorType.secondary
            person_roles[
                'not_registered'] = contrib_person.person not in registered_persons

        return jsonify_template(self.template,
                                event_persons=contribution_persons_dict,
                                event=self.event)
Ejemplo n.º 3
0
 def get_list_kwargs(self):
     if self.check_access:
         self.event.preload_all_acl_entries()
     contributions_query = self._build_query()
     total_entries = (sum(1 for c in contributions_query if c.can_access(session.user)) if self.check_access else
                      contributions_query.count())
     contributions = [c for c in self._filter_list_entries(contributions_query, self.list_config['filters'])
                      if not self.check_access or c.can_access(session.user)]
     sessions = [{'id': s.id, 'title': s.title, 'colors': s.colors} for s in self.event.sessions]
     tracks = [{'id': int(t.id), 'title': t.title_with_group} for t in self.event.tracks]
     total_duration = (sum((c.duration for c in contributions), timedelta()),
                       sum((c.duration for c in contributions if c.timetable_entry), timedelta()))
     selected_entry = request.args.get('selected')
     selected_entry = int(selected_entry) if selected_entry else None
     registered_persons = get_registered_event_persons(self.event)
     return {'contribs': contributions, 'sessions': sessions, 'tracks': tracks, 'total_entries': total_entries,
             'total_duration': total_duration, 'selected_entry': selected_entry,
             'registered_persons': registered_persons}