Exemplo n.º 1
0
def task_get_all(marker=None,
                 limit=None,
                 sort_field=None,
                 sort_dir=None,
                 project_group_id=None,
                 current_user=None,
                 **kwargs):
    # Sanity checks, in case someone accidentally explicitly passes in 'None'
    if not sort_field:
        sort_field = 'id'
    if not sort_dir:
        sort_dir = 'asc'

    # Construct the query
    query = task_build_query(project_group_id,
                             current_user=current_user,
                             **kwargs)

    query = api_base.paginate_query(query=query,
                                    model=models.Task,
                                    limit=limit,
                                    sort_key=sort_field,
                                    marker=marker,
                                    sort_dir=sort_dir)

    # Execute the query
    return query.all()
Exemplo n.º 2
0
def project_get_all(marker=None, offset=None, limit=None, sort_field=None,
                    sort_dir=None, project_group_id=None, subscriber_id=None,
                    **kwargs):
    # Sanity checks, in case someone accidentally explicitly passes in 'None'
    if not sort_field:
        sort_field = 'id'
    if not sort_dir:
        sort_dir = 'asc'

    # Construct the query
    query = project_build_query(project_group_id=project_group_id,
                                **kwargs)

    # Filter by subscriber ID
    if subscriber_id is not None:
        subs = api_base.model_query(models.Subscription)
        subs = api_base.apply_query_filters(query=subs,
                                            model=models.Subscription,
                                            user_id=subscriber_id)
        # Filter by exact match, to avoid matching "project_group"
        subs = subs.filter(models.Subscription.target_type == 'project')
        subs = subs.subquery()
        query = query.join(subs, subs.c.target_id == models.Project.id)

    query = api_base.paginate_query(query=query,
                                    model=models.Project,
                                    limit=limit,
                                    sort_key=sort_field,
                                    marker=marker,
                                    offset=offset,
                                    sort_dir=sort_dir)

    # Execute the query
    return query.all()
Exemplo n.º 3
0
def project_group_get_all(marker=None, limit=None, offset=None,
                          subscriber_id=None, sort_field=None, sort_dir=None,
                          **kwargs):
    # Sanity checks, in case someone accidentally explicitly passes in 'None'
    if not sort_field:
        sort_field = 'id'
    if not sort_dir:
        sort_dir = 'asc'

    query = api_base.model_query(models.ProjectGroup)
    query = api_base.apply_query_filters(query=query,
                                         model=models.ProjectGroup,
                                         **kwargs)

    # Filter by subscriber ID
    if subscriber_id is not None:
        subs = api_base.model_query(models.Subscription)
        subs = api_base.apply_query_filters(query=subs,
                                            model=models.Subscription,
                                            target_type='project_group',
                                            user_id=subscriber_id)
        subs = subs.subquery()
        query = query.join(subs, subs.c.target_id == models.ProjectGroup.id)

    query = api_base.paginate_query(query=query,
                                    model=models.ProjectGroup,
                                    limit=limit,
                                    sort_key=sort_field,
                                    marker=marker,
                                    offset=offset,
                                    sort_dir=sort_dir)

    # Execute the query
    return query.all()
Exemplo n.º 4
0
def get_all(title=None, creator_id=None, user_id=None, project_id=None,
            task_id=None, story_id=None, archived=False, offset=None,
            limit=None, sort_field=None, sort_dir=None, current_user=None,
            item_type=None, **kwargs):
    if sort_field is None:
        sort_field = 'id'
    if sort_dir is None:
        sort_dir = 'asc'

    boards = _build_board_query(title=title,
                                creator_id=creator_id,
                                project_id=project_id,
                                user_id=user_id,
                                archived=archived,
                                current_user=current_user,
                                item_type=item_type,
                                story_id=story_id,
                                task_id=task_id,
                                **kwargs)

    boards = api_base.paginate_query(query=boards,
                                     model=models.Board,
                                     limit=limit,
                                     offset=offset,
                                     sort_key=sort_field,
                                     sort_dir=sort_dir)
    return boards.all()
Exemplo n.º 5
0
def get_all(title=None, creator_id=None, user_id=None, project_id=None,
            task_id=None, story_id=None, archived=False, offset=None,
            limit=None, sort_field=None, sort_dir=None, current_user=None,
            item_type=None, **kwargs):
    if sort_field is None:
        sort_field = 'id'
    if sort_dir is None:
        sort_dir = 'asc'

    boards = _build_board_query(title=title,
                                creator_id=creator_id,
                                project_id=project_id,
                                user_id=user_id,
                                archived=archived,
                                current_user=current_user,
                                item_type=item_type,
                                story_id=story_id,
                                task_id=task_id,
                                **kwargs)

    boards = api_base.paginate_query(query=boards,
                                     model=models.Board,
                                     limit=limit,
                                     offset=offset,
                                     sort_key=sort_field,
                                     sort_dir=sort_dir)
    return boards.all()
Exemplo n.º 6
0
def user_get_all(marker=None, offset=None, limit=None,
                 filter_non_public=False, sort_field=None, sort_dir=None,
                 full_name=None, email=None, openid=None,
                 **kwargs):
    query = _build_user_query(full_name=full_name,
                              email=email,
                              openid=openid)

    query = api_base.paginate_query(query=query,
                                    model=models.User,
                                    limit=limit,
                                    marker=marker,
                                    offset=offset,
                                    sort_key=sort_field,
                                    sort_dir=sort_dir)

    users = query.all()
    if len(users) > 0 and filter_non_public:
        sample_user = users[0]
        public_fields = getattr(sample_user, "_public_fields", [])

        users = [api_base._filter_non_public_fields(user, public_fields)
                 for user in users]

    return users
Exemplo n.º 7
0
def project_group_get_all(marker=None, limit=None, offset=None,
                          subscriber_id=None, sort_field=None, sort_dir=None,
                          **kwargs):
    # Sanity checks, in case someone accidentally explicitly passes in 'None'
    if not sort_field:
        sort_field = 'id'
    if not sort_dir:
        sort_dir = 'asc'

    query = api_base.model_query(models.ProjectGroup)
    query = api_base.apply_query_filters(query=query,
                                         model=models.ProjectGroup,
                                         **kwargs)

    # Filter by subscriber ID
    if subscriber_id is not None:
        subs = api_base.model_query(models.Subscription)
        subs = api_base.apply_query_filters(query=subs,
                                            model=models.Subscription,
                                            target_type='project_group',
                                            user_id=subscriber_id)
        subs = subs.subquery()
        query = query.join(subs, subs.c.target_id == models.ProjectGroup.id)

    query = api_base.paginate_query(query=query,
                                    model=models.ProjectGroup,
                                    limit=limit,
                                    sort_key=sort_field,
                                    marker=marker,
                                    offset=offset,
                                    sort_dir=sort_dir)

    # Execute the query
    return query.all()
Exemplo n.º 8
0
def user_get_all(marker=None,
                 offset=None,
                 limit=None,
                 filter_non_public=False,
                 sort_field=None,
                 sort_dir=None,
                 full_name=None,
                 email=None,
                 openid=None,
                 **kwargs):
    query = _build_user_query(full_name=full_name, email=email, openid=openid)

    query = api_base.paginate_query(query=query,
                                    model=models.User,
                                    limit=limit,
                                    marker=marker,
                                    offset=offset,
                                    sort_key=sort_field,
                                    sort_dir=sort_dir)

    users = query.all()
    if len(users) > 0 and filter_non_public:
        sample_user = users[0]
        public_fields = getattr(sample_user, "_public_fields", [])

        users = [
            api_base._filter_non_public_fields(user, public_fields)
            for user in users
        ]

    return users
Exemplo n.º 9
0
def story_get_all(title=None, description=None, status=None, assignee_id=None,
                  creator_id=None, project_group_id=None, project_id=None,
                  subscriber_id=None, tags=None, marker=None, offset=None,
                  limit=None, tags_filter_type="all", sort_field='id',
                  sort_dir='asc', current_user=None):
    # Sanity checks, in case someone accidentally explicitly passes in 'None'
    if not sort_field:
        sort_field = 'id'
    if not sort_dir:
        sort_dir = 'asc'

    if not isinstance(status, list) and status is not None:
        status = [status]

    # Build the query.
    subquery = _story_build_query(title=title,
                                  description=description,
                                  assignee_id=assignee_id,
                                  creator_id=creator_id,
                                  project_group_id=project_group_id,
                                  project_id=project_id,
                                  tags=tags,
                                  tags_filter_type=tags_filter_type,
                                  current_user=current_user)

    # Filter by subscriber ID
    if subscriber_id is not None:
        subs = api_base.model_query(models.Subscription)
        subs = api_base.apply_query_filters(query=subs,
                                            model=models.Subscription,
                                            target_type='story',
                                            user_id=subscriber_id)
        subs = subs.subquery()
        subquery = subquery.join(subs, subs.c.target_id == models.Story.id)

    # Turn the whole shebang into a subquery.
    subquery = subquery.subquery('filtered_stories')

    # Return the story summary.
    query = api_base.model_query(models.StorySummary)\
        .options(subqueryload(models.StorySummary.tags))
    query = query.join(subquery,
                       models.StorySummary.id == subquery.c.id)

    if status:
        query = query.filter(models.StorySummary.status.in_(status))

    # paginate the query
    query = api_base.paginate_query(query=query,
                                    model=models.StorySummary,
                                    limit=limit,
                                    sort_key=sort_field,
                                    marker=marker,
                                    offset=offset,
                                    sort_dir=sort_dir)

    raw_stories = query.all()
    return raw_stories
Exemplo n.º 10
0
    def _apply_pagination(self, model_cls, query, marker=None, limit=None):

        marker_entity = None
        if marker:
            marker_entity = api_base.entity_get(model_cls, marker, True)

        return api_base.paginate_query(query=query,
                                       model=model_cls,
                                       limit=limit,
                                       sort_key="id",
                                       marker=marker_entity)
Exemplo n.º 11
0
def get_all(title=None,
            creator_id=None,
            project_id=None,
            board_id=None,
            user_id=None,
            story_id=None,
            task_id=None,
            subscriber_id=None,
            sort_field=None,
            sort_dir=None,
            session=None,
            offset=None,
            limit=None,
            archived=False,
            current_user=None,
            hide_lanes=True,
            item_type=None,
            **kwargs):
    if sort_field is None:
        sort_field = 'id'
    if sort_dir is None:
        sort_dir = 'asc'

    if board_id is not None:
        board = boards.get(board_id)
        if board is None:
            return []
        return [
            lane.worklist for lane in board.lanes
            if visible(lane.worklist, current_user)
        ]

    query = _build_worklist_query(title=title,
                                  creator_id=creator_id,
                                  project_id=project_id,
                                  user_id=user_id,
                                  subscriber_id=subscriber_id,
                                  archived=archived,
                                  session=session,
                                  current_user=current_user,
                                  hide_lanes=hide_lanes,
                                  item_type=item_type,
                                  story_id=story_id,
                                  task_id=task_id)

    query = api_base.paginate_query(query=query,
                                    model=models.Worklist,
                                    limit=limit,
                                    offset=offset,
                                    sort_key=sort_field,
                                    sort_dir=sort_dir)
    return query.all()
Exemplo n.º 12
0
    def _apply_pagination(self, model_cls, query, marker=None,
                          offset=None, limit=None):

        marker_entity = None
        if marker:
            marker_entity = api_base.entity_get(model_cls, marker, True)

        return api_base.paginate_query(query=query,
                                       model=model_cls,
                                       limit=limit,
                                       sort_key="id",
                                       marker=marker_entity,
                                       offset=offset)
Exemplo n.º 13
0
def events_get_all(marker=None, offset=None, limit=None, sort_field=None,
                   sort_dir=None, current_user=None, **kwargs):
    if sort_field is None:
        sort_field = 'id'
    if sort_dir is None:
        sort_dir = 'asc'

    query = _events_build_query(current_user=current_user, **kwargs)
    query = api_base.paginate_query(query=query,
                                    model=models.TimeLineEvent,
                                    marker=marker,
                                    limit=limit,
                                    offset=offset,
                                    sort_key=sort_field,
                                    sort_dir=sort_dir)
    return query.all()
Exemplo n.º 14
0
def get_all(name=None, date=None, board_id=None, worklist_id=None,
            user=None, owner=None, sort_field=None, sort_dir=None, **kwargs):
    query = _due_date_build_query(name=name,
                                  date=date,
                                  board_id=board_id,
                                  worklist_id=worklist_id,
                                  user=user,
                                  owner=owner)
    query = api_base.paginate_query(query=query,
                                    model=models.DueDate,
                                    limit=None,
                                    offset=None,
                                    marker=None,
                                    sort_key=sort_field,
                                    sort_dir=sort_dir)
    return query.all()
Exemplo n.º 15
0
def get_all(name=None, date=None, board_id=None, worklist_id=None,
            user=None, owner=None, sort_field=None, sort_dir=None, **kwargs):
    query = _due_date_build_query(name=name,
                                  date=date,
                                  board_id=board_id,
                                  worklist_id=worklist_id,
                                  user=user,
                                  owner=owner)
    query = api_base.paginate_query(query=query,
                                    model=models.DueDate,
                                    limit=None,
                                    offset=None,
                                    marker=None,
                                    sort_key=sort_field,
                                    sort_dir=sort_dir)
    return query.all()
Exemplo n.º 16
0
def branch_get_all(marker=None, limit=None, sort_field=None, sort_dir=None,
                   project_group_id=None, **kwargs):
    if not sort_field:
        sort_field = 'id'
    if not sort_dir:
        sort_dir = 'asc'

    query = branch_build_query(project_group_id=project_group_id,
                               **kwargs)

    query = api_base.paginate_query(query=query,
                                    model=models.Branch,
                                    limit=limit,
                                    sort_key=sort_field,
                                    marker=marker,
                                    sort_dir=sort_dir)

    return query.all()
Exemplo n.º 17
0
    def _apply_pagination(self, model_cls, query, marker=None,
                          offset=None, limit=None, sort_field='id',
                          sort_dir='asc'):
        if not sort_field:
            sort_field = 'id'
        if not sort_dir:
            sort_dir = 'asc'

        marker_entity = None
        if marker:
            marker_entity = api_base.entity_get(model_cls, marker, True)

        return api_base.paginate_query(query=query,
                                       model=model_cls,
                                       limit=limit,
                                       sort_key=sort_field,
                                       marker=marker_entity,
                                       offset=offset,
                                       sort_dir=sort_dir)
Exemplo n.º 18
0
def story_get_all(title=None, description=None, status=None, assignee_id=None,
                  project_group_id=None, project_id=None, tags=None,
                  marker=None, offset=None, limit=None,
                  tags_filter_type="all", sort_field='id', sort_dir='asc'):
    # Sanity checks, in case someone accidentally explicitly passes in 'None'
    if not sort_field:
        sort_field = 'id'
    if not sort_dir:
        sort_dir = 'asc'

    # Build the query.
    subquery = _story_build_query(title=title,
                                  description=description,
                                  assignee_id=assignee_id,
                                  project_group_id=project_group_id,
                                  project_id=project_id,
                                  tags=tags,
                                  tags_filter_type=tags_filter_type)

    # Turn the whole shebang into a subquery.
    subquery = subquery.subquery('filtered_stories')

    # Return the story summary.
    query = api_base.model_query(models.StorySummary)\
        .options(subqueryload(models.StorySummary.tags))
    query = query.join(subquery,
                       models.StorySummary.id == subquery.c.id)

    if status:
        query = query.filter(models.StorySummary.status.in_(status))

    # paginate the query
    query = api_base.paginate_query(query=query,
                                    model=models.StorySummary,
                                    limit=limit,
                                    sort_key=sort_field,
                                    marker=marker,
                                    offset=offset,
                                    sort_dir=sort_dir)

    raw_stories = query.all()
    stories = map(summarize_task_statuses, raw_stories)
    return stories
Exemplo n.º 19
0
def task_get_all(marker=None, limit=None, sort_field=None, sort_dir=None,
                 project_group_id=None, **kwargs):
    # Sanity checks, in case someone accidentally explicitly passes in 'None'
    if not sort_field:
        sort_field = 'id'
    if not sort_dir:
        sort_dir = 'asc'

    # Construct the query
    query = task_build_query(project_group_id, **kwargs)

    query = api_base.paginate_query(query=query,
                                    model=models.Task,
                                    limit=limit,
                                    sort_key=sort_field,
                                    marker=marker,
                                    sort_dir=sort_dir)

    # Execute the query
    return query.all()
Exemplo n.º 20
0
def access_token_get_all(marker=None, limit=None, sort_field=None,
                         sort_dir=None, **kwargs):
    # Sanity checks, in case someone accidentally explicitly passes in 'None'
    if not sort_field:
        sort_field = 'id'
    if not sort_dir:
        sort_dir = 'asc'

    # Construct the query
    query = access_token_build_query(**kwargs)

    query = api_base.paginate_query(query=query,
                                    model=models.AccessToken,
                                    limit=limit,
                                    sort_key=sort_field,
                                    marker=marker,
                                    sort_dir=sort_dir)

    # Execute the query
    return query.all()
Exemplo n.º 21
0
def events_get_all(marker=None,
                   offset=None,
                   limit=None,
                   sort_field=None,
                   sort_dir=None,
                   current_user=None,
                   **kwargs):
    if sort_field is None:
        sort_field = 'id'
    if sort_dir is None:
        sort_dir = 'asc'

    query = _events_build_query(current_user=current_user, **kwargs)
    query = api_base.paginate_query(query=query,
                                    model=models.TimeLineEvent,
                                    marker=marker,
                                    limit=limit,
                                    offset=offset,
                                    sort_key=sort_field,
                                    sort_dir=sort_dir)
    return query.all()
Exemplo n.º 22
0
def user_token_get_all(marker=None, limit=None, sort_field=None,
                       sort_dir=None, **kwargs):
    if not sort_field:
        sort_field = 'id'
    if not sort_dir:
        sort_dir = 'asc'

    query = api_base.model_query(models.AccessToken)

    query = api_base.apply_query_filters(query=query,
                                         model=models.AccessToken,
                                         **kwargs)

    query = api_base.paginate_query(query=query,
                                    model=models.AccessToken,
                                    limit=limit,
                                    sort_key=sort_field,
                                    marker=marker,
                                    sort_dir=sort_dir)

    return query.all()
Exemplo n.º 23
0
def access_token_get_all(marker=None,
                         limit=None,
                         sort_field=None,
                         sort_dir=None,
                         **kwargs):
    # Sanity checks, in case someone accidentally explicitly passes in 'None'
    if not sort_field:
        sort_field = 'id'
    if not sort_dir:
        sort_dir = 'asc'

    # Construct the query
    query = access_token_build_query(**kwargs)

    query = api_base.paginate_query(query=query,
                                    model=models.AccessToken,
                                    limit=limit,
                                    sort_key=sort_field,
                                    marker=marker,
                                    sort_dir=sort_dir)

    # Execute the query
    return query.all()
Exemplo n.º 24
0
def user_token_get_all(marker=None,
                       limit=None,
                       sort_field=None,
                       sort_dir=None,
                       **kwargs):
    if not sort_field:
        sort_field = 'id'
    if not sort_dir:
        sort_dir = 'asc'

    query = api_base.model_query(models.AccessToken)

    query = api_base.apply_query_filters(query=query,
                                         model=models.AccessToken,
                                         **kwargs)

    query = api_base.paginate_query(query=query,
                                    model=models.AccessToken,
                                    limit=limit,
                                    sort_key=sort_field,
                                    marker=marker,
                                    sort_dir=sort_dir)

    return query.all()
Exemplo n.º 25
0
def get_all(title=None, creator_id=None, project_id=None, board_id=None,
            user_id=None, story_id=None, task_id=None, sort_field=None,
            sort_dir=None, session=None, offset=None, limit=None,
            archived=False, current_user=None, hide_lanes=True,
            item_type=None, **kwargs):
    if sort_field is None:
        sort_field = 'id'
    if sort_dir is None:
        sort_dir = 'asc'

    if board_id is not None:
        board = boards.get(board_id)
        if board is None:
            return []
        return [lane.worklist for lane in board.lanes
                if visible(lane.worklist, current_user)]

    query = _build_worklist_query(title=title,
                                  creator_id=creator_id,
                                  project_id=project_id,
                                  user_id=user_id,
                                  archived=archived,
                                  session=session,
                                  current_user=current_user,
                                  hide_lanes=hide_lanes,
                                  item_type=item_type,
                                  story_id=story_id,
                                  task_id=task_id)

    query = api_base.paginate_query(query=query,
                                    model=models.Worklist,
                                    limit=limit,
                                    offset=offset,
                                    sort_key=sort_field,
                                    sort_dir=sort_dir)
    return query.all()
Exemplo n.º 26
0
    def _apply_pagination(self,
                          model_cls,
                          query,
                          marker=None,
                          offset=None,
                          limit=None,
                          sort_field='id',
                          sort_dir='asc'):
        if not sort_field:
            sort_field = 'id'
        if not sort_dir:
            sort_dir = 'asc'

        marker_entity = None
        if marker:
            marker_entity = api_base.entity_get(model_cls, marker, True)

        return api_base.paginate_query(query=query,
                                       model=model_cls,
                                       limit=limit,
                                       sort_key=sort_field,
                                       marker=marker_entity,
                                       offset=offset,
                                       sort_dir=sort_dir)
Exemplo n.º 27
0
def story_get_all(title=None,
                  description=None,
                  status=None,
                  assignee_id=None,
                  creator_id=None,
                  project_group_id=None,
                  project_id=None,
                  subscriber_id=None,
                  tags=None,
                  updated_since=None,
                  board_id=None,
                  worklist_id=None,
                  marker=None,
                  offset=None,
                  limit=None,
                  tags_filter_type="all",
                  sort_field='id',
                  sort_dir='asc',
                  current_user=None):
    # Sanity checks, in case someone accidentally explicitly passes in 'None'
    if not sort_field:
        sort_field = 'id'
    if not sort_dir:
        sort_dir = 'asc'

    if not isinstance(status, list) and status is not None:
        status = [status]

    # Build the query.
    subquery = _story_build_query(title=title,
                                  description=description,
                                  assignee_id=assignee_id,
                                  creator_id=creator_id,
                                  project_group_id=project_group_id,
                                  project_id=project_id,
                                  tags=tags,
                                  updated_since=updated_since,
                                  board_id=board_id,
                                  worklist_id=worklist_id,
                                  current_user=current_user,
                                  tags_filter_type=tags_filter_type)

    # Filter by subscriber ID
    if subscriber_id is not None:
        subs = api_base.model_query(models.Subscription)
        subs = api_base.apply_query_filters(query=subs,
                                            model=models.Subscription,
                                            target_type='story',
                                            user_id=subscriber_id)
        subs = subs.subquery()
        subquery = subquery.join(subs, subs.c.target_id == models.Story.id)

    # Turn the whole shebang into a subquery.
    subquery = subquery.subquery('filtered_stories')

    # Return the story summary.
    query = api_base.model_query(models.StorySummary)\
        .options(subqueryload(models.StorySummary.tags))
    id_col = tuple(subquery.c)[0]
    query = query.join(subquery, models.StorySummary.id == id_col)

    if status:
        query = query.filter(models.StorySummary.status.in_(status))

    # paginate the query
    query = api_base.paginate_query(query=query,
                                    model=models.StorySummary,
                                    limit=limit,
                                    sort_key=sort_field,
                                    marker=marker,
                                    offset=offset,
                                    sort_dir=sort_dir)

    raw_stories = query.all()
    return raw_stories