#NEWLINE# @ loans . route ( '/export/loans/' ) #NEWLINE# @ loans . route ( '/export/loans/made/<direction>' ) #NEWLINE# @ loans . route ( '/export/loans/with/<user>' ) #NEWLINE# @ loans . route ( '/export/loans/for/<date>' ) #NEWLINE# @ loans . route ( '/export/loans/made/<direction>/with/<user>' ) #NEWLINE# @ loans . route ( '/export/loans/made/<direction>/for/<date>' ) #NEWLINE# @ loans . route ( '/export/loans/with/<user>/for/<date>' ) #NEWLINE# @ loans . route ( '/export/loans/made/<direction>/with/<user>/for/<date>' ) #NEWLINE# @ login_required #NEWLINE# def export( direction = None , user = None , date = None ) : #NEWLINE# #INDENT# 'Export loan entries' #NEWLINE# current_user_id = session . get ( 'logged_in_user' ) #NEWLINE# our_loans = Loans ( current_user_id ) #NEWLINE# our_users = Users ( current_user_id ) #NEWLINE# loans = our_loans . get_loans ( ) #NEWLINE# users = our_users . get_connections ( ) #NEWLINE# if user : #NEWLINE# #INDENT# user_id = our_users . is_connection ( slug = user ) #NEWLINE# if user_id : #NEWLINE# #INDENT# loans = our_loans . get_loans ( user_id = user_id ) #NEWLINE# #UNINDENT# #UNINDENT# date_range = translate_date_range ( date ) #NEWLINE# if date_range : #NEWLINE# #INDENT# loans = our_loans . get_loans ( date_from = date_range [ 'low' ] , date_to = date_range [ 'high' ] ) #NEWLINE# #UNINDENT# date_ranges = get_date_ranges ( ) #NEWLINE# if direction : #NEWLINE# #INDENT# loans = our_loans . get_loans ( direction = users ) #NEWLINE# #UNINDENT# response = make_response ( render_template ( 'admin_export_loans.html' , ** locals ( ) ) ) #NEWLINE# response . headers [ 'Content-type' ] = 'text/csv' #NEWLINE# response . headers [ 'Content-disposition' ] = ( ( ( 'attachment;filename=' + 'loans-' ) + str ( today_date ( ) ) ) + '.csv' ) #NEWLINE# return response