#NEWLINE# def build_statement_result( more_id , **data ) : #NEWLINE# #INDENT# result = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# current_page = ( data [ 'start_page' ] + 1 ) #NEWLINE# if ( current_page == data [ 'total_pages' ] ) : #NEWLINE# #INDENT# stmt_pager = Paginator ( data [ 'stmt_list' ] , data [ 'limit' ] ) #NEWLINE# if ( data [ 'format' ] == 'exact' ) : #NEWLINE# #INDENT# result = ( '{"statements": [%s], "more": ""}' % ',' . join ( [ json . dumps ( stmt . to_dict ( data [ 'language' ] , data [ 'format' ] ) , sort_keys = False ) for stmt in Statement . objects . select_related ( 'actor' , 'verb' , 'context_team' , 'context_instructor' , 'authority' , 'object_agent' , 'object_activity' , 'object_substatement' ) . prefetch_related ( 'context_ca_parent' , 'context_ca_grouping' , 'context_ca_category' , 'context_ca_other' ) . filter ( id__in = stmt_pager . page ( current_page ) . object_list ) . order_by ( data [ 'stored' ] ) ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# result [ 'statements' ] = [ stmt . to_dict ( data [ 'language' ] , data [ 'format' ] ) for stmt in Statement . objects . select_related ( 'actor' , 'verb' , 'context_team' , 'context_instructor' , 'authority' , 'object_agent' , 'object_activity' , 'object_substatement' ) . prefetch_related ( 'context_ca_parent' , 'context_ca_grouping' , 'context_ca_category' , 'context_ca_other' ) . filter ( id__in = stmt_pager . page ( current_page ) . object_list ) . order_by ( data [ 'stored' ] ) ] #NEWLINE# result [ 'more' ] = '' #NEWLINE# #UNINDENT# current_page -= 1 #NEWLINE# encoded_list = cache . get ( more_id ) #NEWLINE# decoded_list = json . loads ( encoded_list ) #NEWLINE# decoded_list [ 1 ] = current_page #NEWLINE# encoded_list = json . dumps ( decoded_list ) #NEWLINE# cache . set ( more_id , encoded_list ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# stmt_pager = Paginator ( data [ 'stmt_list' ] , data [ 'limit' ] ) #NEWLINE# cache_key = create_cache_key ( data [ 'stmt_list' ] ) #NEWLINE# if ( data [ 'format' ] == 'exact' ) : #NEWLINE# #INDENT# result = ( '{"statements": [%s], "more": "%s"}' % ( ',' . join ( [ json . dumps ( stmt . to_dict ( data [ 'language' ] , data [ 'format' ] ) , sort_keys = False ) for stmt in Statement . objects . select_related ( 'actor' , 'verb' , 'context_team' , 'context_instructor' , 'authority' , 'object_agent' , 'object_activity' , 'object_substatement' ) . prefetch_related ( 'context_ca_parent' , 'context_ca_grouping' , 'context_ca_category' , 'context_ca_other' ) . filter ( id__in = stmt_pager . page ( current_page ) . object_list ) . order_by ( data [ 'stored' ] ) ] ) , ( ( reverse ( 'lrs:statements_more_placeholder' ) . lower ( ) + '/' ) + cache_key ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# result [ 'statements' ] = [ stmt . to_dict ( data [ 'language' ] , data [ 'format' ] ) for stmt in Statement . objects . select_related ( 'actor' , 'verb' , 'context_team' , 'context_instructor' , 'authority' , 'object_agent' , 'object_activity' , 'object_substatement' ) . prefetch_related ( 'context_ca_parent' , 'context_ca_grouping' , 'context_ca_category' , 'context_ca_other' ) . filter ( id__in = stmt_pager . page ( current_page ) . object_list ) . order_by ( data [ 'stored' ] ) ] #NEWLINE# result [ 'more' ] = ( '%s/%s' % ( reverse ( 'lrs:statements_more_placeholder' ) . lower ( ) , cache_key ) ) #NEWLINE# #UNINDENT# more_cache_list = [ ] #NEWLINE# start_page = current_page #NEWLINE# more_cache_list . append ( data [ 'stmt_list' ] ) #NEWLINE# more_cache_list . append ( start_page ) #NEWLINE# more_cache_list . append ( data [ 'total_pages' ] ) #NEWLINE# more_cache_list . append ( data [ 'limit' ] ) #NEWLINE# more_cache_list . append ( data [ 'attachments' ] ) #NEWLINE# more_cache_list . append ( data [ 'language' ] ) #NEWLINE# more_cache_list . append ( data [ 'format' ] ) #NEWLINE# more_cache_list . append ( data [ 'stored' ] ) #NEWLINE# encoded_list = json . dumps ( more_cache_list ) #NEWLINE# cache . set ( cache_key , encoded_list ) #NEWLINE# #UNINDENT# return result