コード例 #1
0
ファイル: controllers.py プロジェクト: DirkHoffmann/indico
    def _process(self):
        event_principal_query = (EventPrincipal.query.with_parent(self.event)
                                 .filter(EventPrincipal.type == PrincipalType.email,
                                         EventPrincipal.has_management_role('submit')))

        contrib_principal_query = (ContributionPrincipal.find(Contribution.event == self.event,
                                                              ContributionPrincipal.type == PrincipalType.email,
                                                              ContributionPrincipal.has_management_role('submit'))
                                   .join(Contribution)
                                   .options(contains_eager('contribution')))

        session_principal_query = (SessionPrincipal.find(Session.event == self.event,
                                                         SessionPrincipal.type == PrincipalType.email,
                                                         SessionPrincipal.has_management_role())
                                   .join(Session).options(joinedload('session').joinedload('acl_entries')))

        persons = self.get_persons()
        person_list = sorted(persons.viewvalues(), key=lambda x: x['person'].display_full_name.lower())

        num_no_account = 0
        for principal in itertools.chain(event_principal_query, contrib_principal_query, session_principal_query):
            if principal.email not in persons:
                continue
            if not persons[principal.email].get('no_account'):
                persons[principal.email]['roles']['no_account'] = True
                num_no_account += 1

        return WPManagePersons.render_template('management/person_list.html', self.event,
                                               persons=person_list, num_no_account=num_no_account)
コード例 #2
0
    def _process(self):
        event_principal_query = (EventPrincipal.query.with_parent(self.event_new)
                                 .filter(EventPrincipal.type == PrincipalType.email,
                                         EventPrincipal.has_management_role('submit')))

        contrib_principal_query = (ContributionPrincipal.find(Contribution.event_new == self.event_new,
                                                              ContributionPrincipal.type == PrincipalType.email,
                                                              ContributionPrincipal.has_management_role('submit'))
                                   .join(Contribution)
                                   .options(contains_eager('contribution')))

        session_principal_query = (SessionPrincipal.find(Session.event_new == self.event_new,
                                                         SessionPrincipal.type == PrincipalType.email,
                                                         SessionPrincipal.has_management_role())
                                   .join(Session).options(joinedload('session').joinedload('acl_entries')))

        persons = self.get_persons()
        person_list = sorted(persons.viewvalues(),
                             key=lambda x: x['person'].get_full_name(last_name_first=True).lower())

        num_no_account = 0
        for principal in itertools.chain(event_principal_query, contrib_principal_query, session_principal_query):
            if principal.email not in persons:
                continue
            if not persons[principal.email].get('no_account'):
                persons[principal.email]['roles']['no_account'] = True
                num_no_account += 1

        return WPManagePersons.render_template('management/person_list.html', self._conf, event=self.event_new,
                                               persons=person_list, num_no_account=num_no_account)
コード例 #3
0
    def _process(self):
        event_principal_query = (EventPrincipal.query.with_parent(self.event)
                                 .filter(EventPrincipal.type == PrincipalType.email,
                                         EventPrincipal.has_management_permission('submit')))

        contrib_principal_query = (ContributionPrincipal.find(Contribution.event == self.event,
                                                              ContributionPrincipal.type == PrincipalType.email,
                                                              ContributionPrincipal.has_management_permission('submit'))
                                   .join(Contribution)
                                   .options(contains_eager('contribution')))

        session_principal_query = (SessionPrincipal.find(Session.event == self.event,
                                                         SessionPrincipal.type == PrincipalType.email,
                                                         SessionPrincipal.has_management_permission())
                                   .join(Session).options(joinedload('session').joinedload('acl_entries')))

        persons = self.get_persons()
        person_list = sorted(persons.values(), key=lambda x: x['person'].display_full_name.lower())

        num_no_account = 0
        for principal in itertools.chain(event_principal_query, contrib_principal_query, session_principal_query):
            if principal.email not in persons:
                continue
            if not persons[principal.email].get('no_account'):
                persons[principal.email]['roles']['no_account'] = True
                num_no_account += 1
        custom_roles = {f'custom_{r.id}': {'name': r.name, 'code': r.code, 'color': r.color}
                        for r in self.event.roles}
        return WPManagePersons.render_template('management/person_list.html', self.event, persons=person_list,
                                               num_no_account=num_no_account, builtin_roles=BUILTIN_ROLES,
                                               custom_roles=custom_roles)
コード例 #4
0
    def _process(self):
        users = defaultdict(
            lambda: {
                'tracks_convener': defaultdict(dict),
                'tracks_reviewer': defaultdict(dict),
                'roles': defaultdict(lambda: False)
            })

        track_conveners_query = (db.session.query(Event, Track, User).join(
            Event.tracks).join(
                Track.conveners).filter(Track.event_id == self.event.id).all())

        track_reviewers_query = (db.session.query(Event, Track, User).join(
            Event.tracks).join(Track.abstract_reviewers).filter(
                Track.event_id == self.event.id).all())

        for track_user in track_conveners_query:
            data = users[track_user.User.email or track_user.User.id]
            data['user'] = track_user.User
            data['tracks_convener'][track_user.Track.id] = {
                'title': track_user.Track.title
            }
            data['roles']['convener'] = True

        for track_user in track_reviewers_query:
            data = users[track_user.User.email or track_user.User.id]
            data['user'] = track_user.User
            data['tracks_reviewer'][track_user.Track.id] = {
                'title': track_user.Track.title
            }
            data['roles']['reviewer'] = True

        users = {
            email: data
            for email, data in users.viewitems()
            if any(data['roles'].viewvalues())
        }
        user_list = sorted(users.viewvalues(),
                           key=lambda x: x['user'].display_full_name.lower())

        return WPManagePersons.render_template('management/trole_list.html',
                                               self.event,
                                               users=user_list)
コード例 #5
0
ファイル: controllers.py プロジェクト: fph/indico
    def _process(self):
        contribution_strategy = joinedload('contribution_links')
        contribution_strategy.joinedload('contribution')
        contribution_strategy.joinedload('person').joinedload('user')
        subcontribution_strategy = joinedload('subcontribution_links')
        subcontribution_strategy.joinedload('subcontribution')
        subcontribution_strategy.joinedload('person').joinedload('user')
        session_block_strategy = joinedload('session_block_links')
        session_block_strategy.joinedload('session_block')
        session_block_strategy.joinedload('person').joinedload('user')
        event_strategy = joinedload('event_links')
        event_strategy.joinedload('person').joinedload('user')

        event_persons_query = (self.event_new.persons.options(event_strategy, contribution_strategy,
                                                              subcontribution_strategy, session_block_strategy)
                               .all())
        persons = defaultdict(lambda: {'session_blocks': defaultdict(dict), 'contributions': defaultdict(dict),
                                       'subcontributions': defaultdict(dict), 'roles': defaultdict(dict)})

        event_principal_query = (EventPrincipal.query.with_parent(self.event_new)
                                 .filter(EventPrincipal.type == PrincipalType.email,
                                         EventPrincipal.has_management_role('submit')))

        contrib_principal_query = (ContributionPrincipal.find(Contribution.event_new == self.event_new,
                                                              ContributionPrincipal.type == PrincipalType.email,
                                                              ContributionPrincipal.has_management_role('submit'))
                                   .join(Contribution)
                                   .options(contains_eager('contribution')))

        session_principal_query = (SessionPrincipal.find(Session.event_new == self.event_new,
                                                         SessionPrincipal.type == PrincipalType.email,
                                                         SessionPrincipal.has_management_role())
                                   .join(Session).options(joinedload('session').joinedload('acl_entries')))

        chairpersons = {link.person for link in self.event_new.person_links}

        for event_person in event_persons_query:
            data = persons[event_person.email or event_person.id]

            data['person'] = event_person
            data['roles']['chairperson'] = event_person in chairpersons

            for person_link in event_person.session_block_links:
                if person_link.session_block.session.is_deleted:
                    continue

                data['session_blocks'][person_link.session_block_id] = {'title': person_link.session_block.full_title}
                data['roles']['convener'] = True

            for person_link in event_person.contribution_links:
                if not person_link.is_speaker:
                    continue
                contrib = person_link.contribution
                if contrib.is_deleted:
                    continue

                url = url_for('contributions.manage_contributions', self.event_new, selected=contrib.friendly_id)
                data['contributions'][contrib.id] = {'title': contrib.title, 'url': url}
                data['roles']['speaker'] = True

            for person_link in event_person.subcontribution_links:
                subcontrib = person_link.subcontribution
                contrib = subcontrib.contribution
                if subcontrib.is_deleted or contrib.is_deleted:
                    continue

                url = url_for('contributions.manage_contributions', self.event_new, selected=contrib.friendly_id)
                data['subcontributions'][subcontrib.id] = {'title': '{} ({})'.format(contrib.title, subcontrib.title),
                                                           'url': url}
                data['roles']['speaker'] = True

        # Some EventPersons will have no roles since they were connected to deleted things
        persons = {email: data for email, data in persons.viewitems() if
                   any(data['roles'].viewvalues())}

        num_no_account = 0
        for principal in itertools.chain(event_principal_query, contrib_principal_query, session_principal_query):
            if principal.email not in persons:
                continue
            if not persons[principal.email].get('no_account'):
                persons[principal.email]['roles']['no_account'] = True
                num_no_account += 1

        person_list = sorted(persons.viewvalues(), key=lambda x: x['person'].get_full_name(last_name_first=True).lower())

        return WPManagePersons.render_template('management/person_list.html', self._conf, event=self.event_new,
                                               persons=person_list, num_no_account=num_no_account)
コード例 #6
0
ファイル: controllers.py プロジェクト: stomanin/indico
    def _process(self):
        contribution_strategy = joinedload('contribution_links')
        contribution_strategy.joinedload('contribution')
        contribution_strategy.joinedload('person').joinedload('user')
        subcontribution_strategy = joinedload('subcontribution_links')
        subcontribution_strategy.joinedload('subcontribution')
        subcontribution_strategy.joinedload('person').joinedload('user')
        session_block_strategy = joinedload('session_block_links')
        session_block_strategy.joinedload('session_block')
        session_block_strategy.joinedload('person').joinedload('user')
        event_strategy = joinedload('event_links')
        event_strategy.joinedload('person').joinedload('user')

        event_persons_query = (self.event_new.persons.options(event_strategy, contribution_strategy,
                                                              subcontribution_strategy, session_block_strategy)
                               .all())
        persons = defaultdict(lambda: {'session_blocks': defaultdict(dict), 'contributions': defaultdict(dict),
                                       'subcontributions': defaultdict(dict), 'roles': defaultdict(dict)})

        event_principal_query = (EventPrincipal.query.with_parent(self.event_new)
                                 .filter(EventPrincipal.type == PrincipalType.email,
                                         EventPrincipal.has_management_role('submit')))

        contrib_principal_query = (ContributionPrincipal.find(Contribution.event_new == self.event_new,
                                                              ContributionPrincipal.type == PrincipalType.email,
                                                              ContributionPrincipal.has_management_role('submit'))
                                   .join(Contribution)
                                   .options(contains_eager('contribution')))

        session_principal_query = (SessionPrincipal.find(Session.event_new == self.event_new,
                                                         SessionPrincipal.type == PrincipalType.email,
                                                         SessionPrincipal.has_management_role())
                                   .join(Session).options(joinedload('session').joinedload('acl_entries')))

        chairpersons = {link.person for link in self.event_new.person_links}

        for event_person in event_persons_query:
            data = persons[event_person.email or event_person.id]

            data['person'] = event_person
            data['roles']['chairperson'] = event_person in chairpersons

            for person_link in event_person.session_block_links:
                if person_link.session_block.session.is_deleted:
                    continue

                data['session_blocks'][person_link.session_block_id] = {'title': person_link.session_block.full_title}
                data['roles']['convener'] = True

            for person_link in event_person.contribution_links:
                if not person_link.is_speaker:
                    continue
                contrib = person_link.contribution
                if contrib.is_deleted:
                    continue

                url = url_for('contributions.manage_contributions', self.event_new, selected=contrib.friendly_id)
                data['contributions'][contrib.id] = {'title': contrib.title, 'url': url}
                data['roles']['speaker'] = True

            for person_link in event_person.subcontribution_links:
                subcontrib = person_link.subcontribution
                contrib = subcontrib.contribution
                if subcontrib.is_deleted or contrib.is_deleted:
                    continue

                url = url_for('contributions.manage_contributions', self.event_new, selected=contrib.friendly_id)
                data['subcontributions'][subcontrib.id] = {'title': '{} ({})'.format(contrib.title, subcontrib.title),
                                                           'url': url}
                data['roles']['speaker'] = True

        # Some EventPersons will have no roles since they were connected to deleted things
        persons = {email: data for email, data in persons.viewitems() if
                   any(data['roles'].viewvalues())}

        num_no_account = 0
        for principal in itertools.chain(event_principal_query, contrib_principal_query, session_principal_query):
            if principal.email not in persons:
                continue
            if not persons[principal.email].get('no_account'):
                persons[principal.email]['roles']['no_account'] = True
                num_no_account += 1

        person_list = sorted(persons.viewvalues(), key=lambda x: x['person'].get_full_name(last_name_first=True).lower())

        return WPManagePersons.render_template('management/person_list.html', self._conf, event=self.event_new,
                                               persons=person_list, num_no_account=num_no_account)