Пример #1
0
 def export_linked_events(self, aw):
     if not redis_client:
         raise HTTPAPIError('This API is only available when using Redis')
     self._checkProtection(aw)
     links = avatar_links.get_links(self._avatar.user, self._fromDT,
                                    self._toDT)
     for event_id in get_events_registered(self._avatar.user, self._fromDT,
                                           self._toDT):
         links.setdefault(str(event_id),
                          set()).add('registration_registrant')
     for event_id in get_events_with_submitted_surveys(
             self._avatar.user, self._fromDT, self._toDT):
         links.setdefault(str(event_id), set()).add('survey_submitter')
     for event_id in get_events_managed_by(self._avatar.user, self._fromDT,
                                           self._toDT):
         links.setdefault(str(event_id), set()).add('conference_manager')
     for event_id in get_events_created_by(self._avatar.user, self._fromDT,
                                           self._toDT):
         links.setdefault(str(event_id), set()).add('conference_creator')
     for event_id, principal_roles in get_events_with_linked_sessions(
             self._avatar.user, self._fromDT, self._toDT).iteritems():
         links.setdefault(str(event_id), set()).update(principal_roles)
     for event_id, principal_roles in get_events_with_linked_contributions(
             self._avatar.user, self._fromDT, self._toDT).iteritems():
         links.setdefault(str(event_id), set()).update(principal_roles)
     for event_id in get_events_with_linked_event_persons(
             self._avatar.user, self._fromDT, self._toDT):
         links.setdefault(str(event_id), set()).add('conference_chair')
     return UserRelatedEventFetcher(aw, self, links).events(links.keys())
Пример #2
0
def get_linked_events(user, from_dt, to_dt, limit=None):
    """Get the linked events and the user's roles in them"""
    from indico.modules.events.contributions.util import get_events_with_linked_contributions
    from indico.modules.events.registration.util import get_events_registered
    from indico.modules.events.sessions.util import get_events_with_linked_sessions
    from indico.modules.events.surveys.util import get_events_with_submitted_surveys
    from indico.modules.events.util import (get_events_managed_by, get_events_created_by,
                                            get_events_with_linked_event_persons)

    links = avatar_links.get_links(user, from_dt, to_dt) if redis_client else OrderedDict()
    for event_id in get_events_registered(user, from_dt, to_dt):
        links.setdefault(str(event_id), set()).add('registration_registrant')
    for event_id in get_events_with_submitted_surveys(user, from_dt, to_dt):
        links.setdefault(str(event_id), set()).add('survey_submitter')
    for event_id in get_events_managed_by(user, from_dt, to_dt):
        links.setdefault(str(event_id), set()).add('conference_manager')
    for event_id in get_events_created_by(user, from_dt, to_dt):
        links.setdefault(str(event_id), set()).add('conference_creator')
    for event_id, principal_roles in get_events_with_linked_sessions(user, from_dt, to_dt).iteritems():
        links.setdefault(str(event_id), set()).update(principal_roles)
    for event_id, principal_roles in get_events_with_linked_contributions(user, from_dt, to_dt).iteritems():
        links.setdefault(str(event_id), set()).update(principal_roles)
    for event_id in get_events_with_linked_event_persons(user, from_dt, to_dt):
        links.setdefault(str(event_id), set()).add('conference_chair')

    query = (Event.query
             .filter(~Event.is_deleted,
                     Event.id.in_(map(int, links)))
             .options(joinedload('series'),
                      load_only('id', 'category_id', 'title', 'start_dt', 'end_dt',
                                'series_id', 'series_pos', 'series_count'))
             .order_by(Event.start_dt, Event.id))
    if limit is not None:
        query = query.limit(limit)
    return OrderedDict((event, links[str(event.id)]) for event in query)
Пример #3
0
def get_linked_events(user, dt, limit=None, load_also=()):
    """Get the linked events and the user's roles in them

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    :param limit: Max number of events
    """
    from indico.modules.events.abstracts.util import (
        get_events_with_abstract_reviewer_convener,
        get_events_with_abstract_persons)
    from indico.modules.events.contributions.util import get_events_with_linked_contributions
    from indico.modules.events.papers.util import get_events_with_paper_roles
    from indico.modules.events.registration.util import get_events_registered
    from indico.modules.events.sessions.util import get_events_with_linked_sessions
    from indico.modules.events.surveys.util import get_events_with_submitted_surveys
    from indico.modules.events.util import (
        get_events_managed_by, get_events_created_by,
        get_events_with_linked_event_persons)

    links = OrderedDict()
    for event_id in get_events_registered(user, dt):
        links.setdefault(event_id, set()).add('registration_registrant')
    for event_id in get_events_with_submitted_surveys(user, dt):
        links.setdefault(event_id, set()).add('survey_submitter')
    for event_id in get_events_managed_by(user, dt):
        links.setdefault(event_id, set()).add('conference_manager')
    for event_id in get_events_created_by(user, dt):
        links.setdefault(event_id, set()).add('conference_creator')
    for event_id, principal_roles in get_events_with_linked_sessions(
            user, dt).iteritems():
        links.setdefault(event_id, set()).update(principal_roles)
    for event_id, principal_roles in get_events_with_linked_contributions(
            user, dt).iteritems():
        links.setdefault(event_id, set()).update(principal_roles)
    for event_id, role in get_events_with_linked_event_persons(user,
                                                               dt).iteritems():
        links.setdefault(event_id, set()).add(role)
    for event_id, roles in get_events_with_abstract_reviewer_convener(
            user, dt).iteritems():
        links.setdefault(event_id, set()).update(roles)
    for event_id, roles in get_events_with_abstract_persons(user,
                                                            dt).iteritems():
        links.setdefault(event_id, set()).update(roles)
    for event_id, roles in get_events_with_paper_roles(user, dt).iteritems():
        links.setdefault(event_id, set()).update(roles)

    if not links:
        return OrderedDict()

    query = (Event.query.filter(
        ~Event.is_deleted, Event.id.in_(links)).options(
            joinedload('series'), joinedload('label'),
            load_only('id', 'category_id', 'title', 'start_dt', 'end_dt',
                      'series_id', 'series_pos', 'series_count', 'label_id',
                      'label_message',
                      *load_also)).order_by(Event.start_dt, Event.id))
    if limit is not None:
        query = query.limit(limit)
    return OrderedDict((event, links[event.id]) for event in query)
Пример #4
0
def get_linked_events(user, dt, limit=None):
    """Get the linked events and the user's roles in them

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    :param limit: Max number of events
    """
    from indico.modules.events.abstracts.util import (get_events_with_abstract_reviewer_convener,
                                                      get_events_with_abstract_persons)
    from indico.modules.events.contributions.util import get_events_with_linked_contributions
    from indico.modules.events.registration.util import get_events_registered
    from indico.modules.events.sessions.util import get_events_with_linked_sessions
    from indico.modules.events.surveys.util import get_events_with_submitted_surveys
    from indico.modules.events.util import (get_events_managed_by, get_events_created_by,
                                            get_events_with_linked_event_persons)

    links = avatar_links.get_links(user, dt) if redis_client else OrderedDict()
    allowed_redis_links = {'conference_editor', 'conference_paperReviewManager', 'conference_referee',
                           'conference_reviewer'}
    for event_id, event_links in links.items():
        event_links &= allowed_redis_links
        if not event_links:
            del links[event_id]
    for event_id in get_events_registered(user, dt):
        links.setdefault(str(event_id), set()).add('registration_registrant')
    for event_id in get_events_with_submitted_surveys(user, dt):
        links.setdefault(str(event_id), set()).add('survey_submitter')
    for event_id in get_events_managed_by(user, dt):
        links.setdefault(str(event_id), set()).add('conference_manager')
    for event_id in get_events_created_by(user, dt):
        links.setdefault(str(event_id), set()).add('conference_creator')
    for event_id, principal_roles in get_events_with_linked_sessions(user, dt).iteritems():
        links.setdefault(str(event_id), set()).update(principal_roles)
    for event_id, principal_roles in get_events_with_linked_contributions(user, dt).iteritems():
        links.setdefault(str(event_id), set()).update(principal_roles)
    for event_id in get_events_with_linked_event_persons(user, dt):
        links.setdefault(str(event_id), set()).add('conference_chair')
    for event_id, roles in get_events_with_abstract_reviewer_convener(user, dt).iteritems():
        links.setdefault(str(event_id), set()).update(roles)
    for event_id, roles in get_events_with_abstract_persons(user, dt).iteritems():
        links.setdefault(str(event_id), set()).update(roles)

    if not links:
        return OrderedDict()

    query = (Event.query
             .filter(~Event.is_deleted,
                     Event.id.in_(map(int, links)))
             .options(joinedload('series'),
                      load_only('id', 'category_id', 'title', 'start_dt', 'end_dt',
                                'series_id', 'series_pos', 'series_count'))
             .order_by(Event.start_dt, Event.id))
    if limit is not None:
        query = query.limit(limit)
    return OrderedDict((event, links[str(event.id)]) for event in query)
Пример #5
0
 def export_linked_events(self, aw):
     if not redis_client:
         raise HTTPAPIError('This API is only available when using Redis')
     self._checkProtection(aw)
     links = avatar_links.get_links(self._avatar.user, self._fromDT, self._toDT)
     for event_id in get_events_registered(self._avatar.user, self._fromDT, self._toDT):
         links.setdefault(str(event_id), set()).add('registration_registrant')
     for event_id in get_events_with_submitted_surveys(self._avatar.user, self._fromDT, self._toDT):
         links.setdefault(str(event_id), set()).add('survey_submitter')
     for event_id in get_events_managed_by(self._avatar.user, self._fromDT, self._toDT):
         links.setdefault(str(event_id), set()).add('conference_manager')
     for event_id in get_events_created_by(self._avatar.user, self._fromDT, self._toDT):
         links.setdefault(str(event_id), set()).add('conference_creator')
     for event_id, principal_roles in get_events_with_linked_sessions(self._avatar.user, self._fromDT,
                                                                      self._toDT).iteritems():
         links.setdefault(str(event_id), set()).update(principal_roles)
     for event_id, principal_roles in get_events_with_linked_contributions(self._avatar.user, self._fromDT,
                                                                           self._toDT).iteritems():
         links.setdefault(str(event_id), set()).update(principal_roles)
     for event_id in get_events_with_linked_event_persons(self._avatar.user, self._fromDT, self._toDT):
         links.setdefault(str(event_id), set()).add('conference_chair')
     return UserRelatedEventFetcher(aw, self, links).events(links.keys())
Пример #6
0
def get_linked_events(user, dt, limit=None):
    """Get the linked events and the user's roles in them

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    :param limit: Max number of events
    """
    from indico.modules.events.abstracts.util import (
        get_events_with_abstract_reviewer_convener,
        get_events_with_abstract_persons)
    from indico.modules.events.contributions.util import get_events_with_linked_contributions
    from indico.modules.events.registration.util import get_events_registered
    from indico.modules.events.sessions.util import get_events_with_linked_sessions
    from indico.modules.events.surveys.util import get_events_with_submitted_surveys
    from indico.modules.events.util import (
        get_events_managed_by, get_events_created_by,
        get_events_with_linked_event_persons)

    links = avatar_links.get_links(user, dt) if redis_client else OrderedDict()
    allowed_redis_links = {
        'conference_editor', 'conference_paperReviewManager',
        'conference_referee', 'conference_reviewer'
    }
    for event_id, event_links in links.items():
        event_links &= allowed_redis_links
        if not event_links:
            del links[event_id]
    for event_id in get_events_registered(user, dt):
        links.setdefault(str(event_id), set()).add('registration_registrant')
    for event_id in get_events_with_submitted_surveys(user, dt):
        links.setdefault(str(event_id), set()).add('survey_submitter')
    for event_id in get_events_managed_by(user, dt):
        links.setdefault(str(event_id), set()).add('conference_manager')
    for event_id in get_events_created_by(user, dt):
        links.setdefault(str(event_id), set()).add('conference_creator')
    for event_id, principal_roles in get_events_with_linked_sessions(
            user, dt).iteritems():
        links.setdefault(str(event_id), set()).update(principal_roles)
    for event_id, principal_roles in get_events_with_linked_contributions(
            user, dt).iteritems():
        links.setdefault(str(event_id), set()).update(principal_roles)
    for event_id in get_events_with_linked_event_persons(user, dt):
        links.setdefault(str(event_id), set()).add('conference_chair')
    for event_id, roles in get_events_with_abstract_reviewer_convener(
            user, dt).iteritems():
        links.setdefault(str(event_id), set()).update(roles)
    for event_id, roles in get_events_with_abstract_persons(user,
                                                            dt).iteritems():
        links.setdefault(str(event_id), set()).update(roles)

    if not links:
        return OrderedDict()

    query = (Event.query.filter(~Event.is_deleted, Event.id.in_(map(
        int, links))).options(
            joinedload('series'),
            load_only('id', 'category_id', 'title', 'start_dt', 'end_dt',
                      'series_id', 'series_pos',
                      'series_count')).order_by(Event.start_dt, Event.id))
    if limit is not None:
        query = query.limit(limit)
    return OrderedDict((event, links[str(event.id)]) for event in query)