def fix_reg_approved_log_params(targets): """ Restores params['registration'] field """ logger.info('Migrating registration_approved logs.') count = 0 for log in targets: log.params['registration'] = RegistrationApproval.load(log.params['registration_approval_id'])._get_registration()._id logger.info( 'Updating params[registration] of log {}. params[node]={}, params[registration]={}'.format( log._id, log.params['node'], log.params['registration'], log.original_node)) log.save() count += 1 logger.info('{} logs migrated'.format(count))
def migrate_log(logs): """ Migrates registration logs to set params['node'] to registered_from and params['registration'] to the registration. """ logs_count = logs.count() count = 0 for log in logs: count += 1 node = log.params.get('node') or log.params.get('project') params_node = Node.load(node) if params_node.is_registration: log.params['node'] = get_registered_from(params_node) log.params['registration'] = params_node._id else: # For logs where params['node'] already equal to node (registration_approval logs, and logs with errors in registration_cancelled) log.params['registration'] = RegistrationApproval.load(log.params['registration_approval_id'])._get_registration()._id log.save() 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']))
def migrate_log(logs): """ Migrates registration logs to set params['node'] to registered_from and params['registration'] to the registration. """ logs_count = logs.count() count = 0 for log in logs: count += 1 node = log.params.get('node') or log.params.get('project') params_node = Node.load(node) if params_node.is_registration: log.params['node'] = get_registered_from(params_node) log.params['registration'] = params_node._id else: # For logs where params['node'] already equal to node (registration_approval logs, and logs with errors in registration_cancelled) log.params['registration'] = RegistrationApproval.load( log.params['registration_approval_id'])._get_registration()._id log.save() 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']))