예제 #1
0
파일: expenses.py 프로젝트: ivabz/kharcha
def available_reports(user=None):
    if user is None:
        user = g.user
    query = ExpenseReport.query.order_by('datetime')
    if 'reviewer' in lastuser.permissions():
        # Get all reports owned by this user and in states where the user can review them
        query = ExpenseReport.query.filter(db.or_(
            ExpenseReport.user == user,
            ExpenseReport.status.in_(ExpenseReportWorkflow.reviewable.values)))
    else:
        query = ExpenseReport.query.filter_by(user=user)
    return query
예제 #2
0
def reports():
    # Sort reports by status
    query = ExpenseReport.query.order_by('updated_at')
    if 'reviewer' in lastuser.permissions():
        # Get all reports owned by this user and in states where the user can review them
        query = ExpenseReport.query.filter(db.or_(
            ExpenseReport.user == g.user,
            ExpenseReport.status.in_(ExpenseReportWorkflow.reviewable.value)))
    else:
        query = ExpenseReport.query.filter_by(user=g.user)
    reports = ExpenseReportWorkflow.sort_documents(query.order_by('updated_at').all())
    return render_template('reports.html', reports=reports)
예제 #3
0
파일: expenses.py 프로젝트: Anenth/kharcha
def available_reports(workspace, user=None, all=False):
    if user is None:
        user = g.user
    query = ExpenseReport.query.filter_by(workspace=workspace).order_by('datetime')
    # FIXME+TODO: Replace with per-workspace permissions
    if all and 'review' in g.permissions:
        # Get all reports owned by this user and in states where the user can review them
        query = query.filter(db.or_(
            ExpenseReport.user == user,
            ExpenseReport.status.in_(ExpenseReportWorkflow.reviewable.values)))
    else:
        query = query.filter_by(user=user)
    return query
예제 #4
0
def reports():
    # Sort reports by status
    query = ExpenseReport.query.order_by('updated_at')
    if 'reviewer' in lastuser.permissions():
        # Get all reports owned by this user and in states where the user can review them
        query = ExpenseReport.query.filter(
            db.or_(
                ExpenseReport.user == g.user,
                ExpenseReport.status.in_(
                    ExpenseReportWorkflow.reviewable.value)))
    else:
        query = ExpenseReport.query.filter_by(user=g.user)
    reports = ExpenseReportWorkflow.sort_documents(
        query.order_by('updated_at').all())
    return render_template('reports.html', reports=reports)
예제 #5
0
def available_reports(workspace, user=None, all=False):
    if user is None:
        user = g.user
    query = ExpenseReport.query.filter_by(
        workspace=workspace).order_by('datetime')
    # FIXME+TODO: Replace with per-workspace permissions
    if all and 'review' in g.permissions:
        # Get all reports owned by this user and in states where the user can review them
        query = query.filter(
            db.or_(
                ExpenseReport.user == user,
                ExpenseReport.status.in_(
                    ExpenseReportWorkflow.reviewable.values)))
    else:
        query = query.filter_by(user=user)
    return query