Esempio n. 1
0
def query(subject,assign_to,category_id,status_open,status_fixed,status_closed,status_canceled,order_by,page_no):
    session = database.get_session()

    filters = []
    status = []

    subject = subject.strip()
    if len(subject) > 0:
        filters.append(Issue.Subject.like('%' + subject + '%'))
    if not assign_to == 0:
        filters.append(Issue.AssignTo == assign_to)
    if not category_id == -1:
        filters.append(Issue.CategoryId == category_id)
    if status_open:
        status.append(IssueStatus.Open)
    if status_fixed:
        status.append(IssueStatus.Fixed)
    if status_closed:
        status.append(IssueStatus.Closed)
    if status_canceled:
        status.append(IssueStatus.Canceled)
    if len(status) > 0:
        filters.append(Issue.Status.in_(status))

    q = session.query(Issue).join(UserProfile,UserProfile.UserId == Issue.Creator).join(UserProfile,UserProfile.UserId == Issue.AssignTo)
    for f in filters:
        q = q.filter(f)
    (row_count,page_count,page_no,page_size,data) = database.pager(q,order_by,page_no,PAGESIZE)

    session.close()
    return (row_count,page_count,page_no,page_size,data)
Esempio n. 2
0
def query(task_name,assign_to,status_new,status_in_progress,status_completed,status_canceled,order_by,page_no):
    session = database.get_session()

    filters = []
    status = []

    task_name = task_name.strip()
    if len(task_name) > 0:
        filters.append(Task.TaskName.like('%' + task_name + '%'))
    if not assign_to == 0:
        filters.append(Task.AssignTo == assign_to)
    if status_new:
        status.append(TaskStatus.New)
    if status_in_progress:
        status.append(TaskStatus.InProgress)
    if status_completed:
        status.append(TaskStatus.Completed)
    if status_canceled:
        status.append(TaskStatus.Canceled)
    if len(status) > 0:
        filters.append(Task.Status.in_(status))

    q = session.query(Task).join(UserProfile,UserProfile.UserId == Task.Creator).join(UserProfile,UserProfile.UserId == Task.AssignTo)
    for f in filters:
        q = q.filter(f)
    (row_count,page_count,page_no,page_size,data) = database.pager(q,order_by,page_no,PAGESIZE)

    session.close()
    return (row_count,page_count,page_no,page_size,data)
Esempio n. 3
0
def query_user(mail_or_nick,status,order_by,page_no):
    session = database.get_session()

    filters = []
    if len(mail_or_nick) > 0:
        filters.append(or_(UserProfile.Email.like('%' + mail_or_nick + '%'), UserProfile.Nick.like('%' + mail_or_nick + '%')))
    if not status == -1:
        filters.append(UserProfile.Status == status)

    q = session.query(UserProfile)
    for f in filters:
        q = q.filter(f)

    (row_count,page_count,page_no,page_size,data) = database.pager(q,order_by,page_no,PAGESIZE)
    session.close()

    return (row_count,page_count,page_no,page_size,data)
Esempio n. 4
0
def query(project_name, status, page_no, order_by, current_user):
    filters = []
    project_name = project_name.strip()
    if len(project_name) > 0:
        filters.append(Project.ProjectName.like("%" + project_name + "%"))
    if not status == "-1":
        filters.append(Project.Status == status)

    session = database.get_session()

    project_list = session.query(Member.ProjectId).filter(Member.UserId == current_user)

    q = session.query(Project).filter(Project.ProjectId.in_(project_list))
    for f in filters:
        q = q.filter(f)
    (row_count, page_count, page_no, page_size, data) = database.pager(q, order_by, page_no)

    session.close()
    return (row_count, page_count, page_no, page_size, data)