#NEWLINE# def migrate_log( logs ) : #NEWLINE# #INDENT# "\n    Migrates registration logs to set params['node'] to registered_from and params['registration'] to the registration.\n    " #NEWLINE# logs_count = logs . count ( ) #NEWLINE# count = 0 #NEWLINE# for log in params_node : #NEWLINE# #INDENT# count += 1 #NEWLINE# node = ( log . params . get ( 'node' ) or log . params . get ( 'project' ) ) #NEWLINE# params_node = Node . load ( node ) #NEWLINE# if params_node . is_registration : #NEWLINE# #INDENT# log . params [ 'node' ] = get_registered_from ( params_node ) #NEWLINE# log . params [ 'registration' ] = params_node . _id #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# log . params [ 'registration' ] = RegistrationApproval . load ( log . params [ 'registration_approval_id' ] ) . _get_registration ( ) . _id #NEWLINE# #UNINDENT# log . save ( ) #NEWLINE# logger . info ( '{}/{} Finished migrating log {}: registration action {}. params[node]={} and params[registration]={}' . format ( count , logs_count , log . _id , log . action , log . params [ 'node' ] , log . params [ 'registration' ] ) )