예제 #1
0
def get_events_with_abstract_persons(user, dt=None):
    """
    Return a dict of event ids and the abstract submission related
    roles the user has in that event.

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    """
    data = defaultdict(set)
    bad_states = {AbstractState.withdrawn, AbstractState.rejected}
    # submitter
    query = (Abstract.query
             .filter(~Event.is_deleted,
                     ~Abstract.is_deleted,
                     ~Abstract.state.in_(bad_states),
                     Event.ends_after(dt),
                     Abstract.submitter == user)
             .join(Abstract.event_new)
             .options(load_only('event_id')))
    for abstract in query:
        data[abstract.event_id].add('abstract_submitter')
    # person
    abstract_criterion = db.and_(~Abstract.state.in_(bad_states), ~Abstract.is_deleted)
    query = (user.event_persons
             .filter(~Event.is_deleted,
                     Event.ends_after(dt),
                     EventPerson.abstract_links.any(AbstractPersonLink.abstract.has(abstract_criterion)))
             .join(EventPerson.event_new)
             .options(load_only('event_id')))
    for person in query:
        data[person.event_id].add('abstract_person')
    return data
예제 #2
0
def get_events_with_abstract_reviewer_convener(user, dt=None):
    """
    Return a dict of event ids and the abstract reviewing related
    roles the user has in that event.

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    """
    data = defaultdict(set)
    # global reviewer/convener
    mapping = {'global_abstract_reviewer_for_events': 'abstract_reviewer',
               'global_convener_for_events': 'track_convener'}
    for rel, role in mapping.iteritems():
        query = (Event.query.with_parent(user, rel)
                 .filter(Event.ends_after(dt), ~Event.is_deleted)
                 .options(load_only('id')))
        for event in query:
            data[event.id].add(role)
    # track reviewer/convener
    mapping = {'abstract_reviewer_for_tracks': 'abstract_reviewer',
               'convener_for_tracks': 'track_convener'}
    for rel, role in mapping.iteritems():
        query = (Track.query.with_parent(user, rel)
                 .join(Track.event_new)
                 .filter(Event.ends_after(dt), ~Event.is_deleted)
                 .options(load_only('event_id')))
        for track in query:
            data[track.event_id].add(role)
    return data
예제 #3
0
파일: util.py 프로젝트: DirkHoffmann/indico
def get_events_with_linked_sessions(user, dt=None):
    """Returns a dict with keys representing event_id and the values containing
    data about the user rights for sessions within the event

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    """
    query = (user.in_session_acls
             .options(load_only('session_id', 'roles', 'full_access', 'read_access'))
             .options(noload('*'))
             .options(contains_eager(SessionPrincipal.session).load_only('event_id'))
             .join(Session)
             .join(Event, Event.id == Session.event_id)
             .filter(~Session.is_deleted, ~Event.is_deleted, Event.ends_after(dt)))
    data = defaultdict(set)
    for principal in query:
        roles = data[principal.session.event_id]
        if 'coordinate' in principal.roles:
            roles.add('session_coordinator')
        if 'submit' in principal.roles:
            roles.add('session_submission')
        if principal.full_access:
            roles.add('session_manager')
        if principal.read_access:
            roles.add('session_access')
    return data
예제 #4
0
파일: util.py 프로젝트: mkopcic/indico
def get_events_with_paper_roles(user, dt=None):
    """
    Get the IDs and PR roles of events where the user has any kind
    of paper reviewing privileges.

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    :return: A dict mapping event IDs to a set of roles
    """
    paper_permissions = {
        'paper_manager', 'paper_judge', 'paper_content_reviewer',
        'paper_layout_reviewer'
    }
    role_criteria = [
        EventPrincipal.has_management_permission(permission, explicit=True)
        for permission in paper_permissions
    ]
    query = (user.in_event_acls.join(Event).options(
        noload('user'), noload('local_group'),
        load_only('event_id',
                  'permissions')).filter(~Event.is_deleted,
                                         Event.ends_after(dt)).filter(
                                             db.or_(*role_criteria)))
    return {
        principal.event_id: set(principal.permissions) & paper_permissions
        for principal in query
    }
예제 #5
0
파일: util.py 프로젝트: innovexa/IDC-Events
def get_events_with_linked_sessions(user, dt=None):
    """Returns a dict with keys representing event_id and the values containing
    data about the user rights for sessions within the event

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    """
    query = (user.in_session_acls.options(
        load_only('session_id', 'permissions', 'full_access',
                  'read_access')).options(noload('*')).options(
                      contains_eager(SessionPrincipal.session).load_only(
                          'event_id')).join(Session).join(
                              Event, Event.id == Session.event_id).filter(
                                  ~Session.is_deleted, ~Event.is_deleted,
                                  Event.ends_after(dt)))
    data = defaultdict(set)
    for principal in query:
        roles = data[principal.session.event_id]
        if 'coordinate' in principal.permissions:
            roles.add('session_coordinator')
        if 'submit' in principal.permissions:
            roles.add('session_submission')
        if principal.full_access:
            roles.add('session_manager')
        if principal.read_access:
            roles.add('session_access')
    return data
예제 #6
0
파일: util.py 프로젝트: indico/indico
def get_events_created_by(user, dt=None):
    """Gets the IDs of events created by the user

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    :return: A set of event ids
    """
    query = (user.created_events
             .filter(~Event.is_deleted, Event.ends_after(dt))
             .options(load_only('id')))
    return {event.id for event in query}
예제 #7
0
def get_events_with_linked_event_persons(user, dt=None):
    """Returns a list of all events for which the user is an EventPerson

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    """
    query = (user.event_persons.options(load_only('event_id')).options(
        noload('*')).join(Event, Event.id == EventPerson.event_id).filter(
            EventPerson.event_links.any()).filter(~Event.is_deleted,
                                                  Event.ends_after(dt)))
    return {ep.event_id for ep in query}
예제 #8
0
파일: util.py 프로젝트: qroques/indico
def get_events_created_by(user, dt=None):
    """Gets the IDs of events created by the user

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    :return: A set of event ids
    """
    query = (user.created_events.filter(~Event.is_deleted,
                                        Event.ends_after(dt)).options(
                                            load_only('id')))
    return {event.id for event in query}
예제 #9
0
파일: util.py 프로젝트: qroques/indico
def get_events_managed_by(user, dt=None):
    """Gets the IDs of events where the user has management privs.

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    :return: A set of event ids
    """
    query = (user.in_event_acls.join(Event).options(
        noload('user'), noload('local_group'), load_only('event_id')).filter(
            ~Event.is_deleted, Event.ends_after(dt)).filter(
                EventPrincipal.has_management_role('ANY')))
    return {principal.event_id for principal in query}
예제 #10
0
def get_events_with_linked_event_persons(user, dt=None):
    """Returns a list of all events for which the user is an EventPerson

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    """
    query = (user.event_persons
             .options(load_only('event_id'))
             .options(noload('*'))
             .join(Event, Event.id == EventPerson.event_id)
             .filter(EventPerson.event_links.any())
             .filter(~Event.is_deleted, Event.ends_after(dt)))
    return {ep.event_id for ep in query}
예제 #11
0
def get_events_with_submitted_surveys(user, dt=None):
    """Gets the IDs of events where the user submitted a survey.

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    :return: A set of event ids
    """
    # Survey submissions are not stored in links anymore, so we need to get them directly
    query = (user.survey_submissions.options(load_only('survey_id')).options(
        joinedload(SurveySubmission.survey).load_only('event_id')).join(
            Survey).join(Event).filter(~Survey.is_deleted, ~Event.is_deleted,
                                       Event.ends_after(dt)))
    return {submission.survey.event_id for submission in query}
예제 #12
0
파일: util.py 프로젝트: indico/indico
def get_events_managed_by(user, dt=None):
    """Gets the IDs of events where the user has management privs.

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    :return: A set of event ids
    """
    query = (user.in_event_acls
             .join(Event)
             .options(noload('user'), noload('local_group'), load_only('event_id'))
             .filter(~Event.is_deleted, Event.ends_after(dt))
             .filter(EventPrincipal.has_management_permission('ANY')))
    return {principal.event_id for principal in query}
예제 #13
0
def get_events_with_linked_event_persons(user, dt=None):
    """
    Return a dict containing the event ids and role for all events
    where the user is a chairperson or (in case of a lecture) speaker.

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    """
    query = (user.event_persons
             .with_entities(EventPerson.event_id, Event._type)
             .join(Event, Event.id == EventPerson.event_id)
             .filter(EventPerson.event_links.any())
             .filter(~Event.is_deleted, Event.ends_after(dt)))
    return {event_id: ('lecture_speaker' if event_type == EventType.lecture else 'conference_chair')
            for event_id, event_type in query}
예제 #14
0
파일: util.py 프로젝트: indico/indico
def get_events_with_linked_event_persons(user, dt=None):
    """
    Returns a dict containing the event ids and role for all events
    where the user is a chairperson or (in case of a lecture) speaker.

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    """
    query = (user.event_persons
             .with_entities(EventPerson.event_id, Event._type)
             .join(Event, Event.id == EventPerson.event_id)
             .filter(EventPerson.event_links.any())
             .filter(~Event.is_deleted, Event.ends_after(dt)))
    return {event_id: ('lecture_speaker' if event_type == EventType.lecture else 'conference_chair')
            for event_id, event_type in query}
예제 #15
0
파일: util.py 프로젝트: OmeGak/indico
def get_events_with_submitted_surveys(user, dt=None):
    """Gets the IDs of events where the user submitted a survey.

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    :return: A set of event ids
    """
    # Survey submissions are not stored in links anymore, so we need to get them directly
    query = (user.survey_submissions
             .options(load_only('survey_id'))
             .options(joinedload(SurveySubmission.survey).load_only('event_id'))
             .join(Survey)
             .join(Event)
             .filter(~Survey.is_deleted, ~Event.is_deleted, Event.ends_after(dt)))
    return {submission.survey.event_id for submission in query}
예제 #16
0
def get_events_with_abstract_reviewer_convener(user, dt=None):
    """
    Return a dict of event ids and the abstract reviewing related
    roles the user has in that event.

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    """
    data = defaultdict(set)
    # global reviewer/convener

    event_query = (user.in_event_acls
                   .join(Event)
                   .options(noload('*'), load_only('event_id', 'permissions'))
                   .filter(Event.ends_after(dt), ~Event.is_deleted))
    for principal in event_query:
        roles = data[principal.event_id]
        if 'review_all_abstracts' in principal.permissions:
            roles.add('abstract_reviewer')
        if 'convene_all_abstracts' in principal.permissions:
            roles.add('track_convener')

    query = (user.in_track_acls
             .join(TrackPrincipal.track)
             .join(Track.event)
             .options(load_only('track_id', 'permissions'))
             .options(noload('*'))
             .options(contains_eager(TrackPrincipal.track).load_only('event_id'))
             .filter(Event.ends_after(dt), ~Event.is_deleted))
    for principal in query:
        roles = data[principal.track.event_id]
        if 'review' in principal.permissions:
            roles.add('abstract_reviewer')
        if 'convene' in principal.permissions:
            roles.add('track_convener')
    return data
예제 #17
0
파일: util.py 프로젝트: DirkHoffmann/indico
def get_events_with_paper_roles(user, dt=None):
    """
    Get the IDs and PR roles of events where the user has any kind
    of paper reviewing privileges.

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    :return: A dict mapping event IDs to a set of roles
    """
    paper_roles = {'paper_manager', 'paper_judge', 'paper_content_reviewer', 'paper_layout_reviewer'}
    role_criteria = [EventPrincipal.has_management_role(role, explicit=True) for role in paper_roles]
    query = (user.in_event_acls
             .join(Event)
             .options(noload('user'), noload('local_group'), load_only('event_id', 'roles'))
             .filter(~Event.is_deleted, Event.ends_after(dt))
             .filter(db.or_(*role_criteria)))
    return {principal.event_id: set(principal.roles) & paper_roles for principal in query}