@loans.route('/loans/')
@loans.route('/loans/made/<direction>')
@loans.route('/loans/with/<user>')
@loans.route('/loans/for/<date>')
@loans.route('/loans/page/<int:page>')
@loans.route('/loans/made/<direction>/page/<int:page>')
@loans.route('/loans/with/<user>/page/<int:page>')
@loans.route('/loans/for/<date>/page/<int:page>')
@loans.route('/loans/made/<direction>/with/<user>')
@loans.route('/loans/made/<direction>/with/<user>/page/<int:page>')
@loans.route('/loans/made/<direction>/for/<date>')
@loans.route('/loans/made/<direction>/for/<date>/page/<int:page>')
@loans.route('/loans/with/<user>/for/<date>')
@loans.route('/loans/with/<user>/for/<date>/page/<int:page>')
@loans.route('/loans/made/<direction>/with/<user>/for/<date>')
@loans.route('/loans/made/<direction>/with/<user>/for/<date>/page/<int:page>')
@login_required
def index(direction=None, user=None, date=None, page=1, items_per_page=10):

    current_user_id = session.get('logged_in_user')

    our_loans = Loans(current_user_id)
    our_users = Users(current_user_id)

    # fetch loans
    loans = our_loans.get_loans()

    # fetch users from connections from us
    users = our_users.get_connections()

    # provided user?
    if user:
        # valid slug?
        user_id = our_users.is_connection(slug=user)
        if user_id: loans = our_loans.get_loans(user_id=user_id)

    # provided a date range?
    date_range = translate_date_range(date)
    if date_range:
        loans = our_loans.get_loans(date_from=date_range['low'], date_to=date_range['high'])
    # date ranges for the template
    date_ranges = get_date_ranges()

    # provided a direction?
    if direction: loans = our_loans.get_loans(direction=direction)

    # build a paginator
    paginator = Pagination(loans, page, items_per_page, loans.count(),
                           loans.offset((page - 1) * items_per_page).limit(items_per_page))

    return render_template('admin_show_loans.html', **locals())
List loans user has with other users
dataset/ETHPy150Open radekstepan/FlaskBudget/presenters/loans.py/index