def migrate_registrations_q5_metadata(schema):
 registrations = Node.find((Q('is_registration', 'eq', True) & Q('registered_schema', 'eq', schema)))
 total_reg = registrations.count()
 logger.info('Examining {} registrations for q5 metadata'.format(total_reg))
 reg_count = 0
 for reg in registrations:
  reg_count += 1
  if reg.registered_meta.get(schema._id, {}).get('q5', {}).get('value', {}):
   reg.registered_meta[schema._id]['q5']['value'] = reg.registered_meta[schema._id]['q5']['value'].rstrip()
   reg.save()
   logger.info('{}/{} Migrated q5 response for {}'.format(reg_count, total_reg, reg._id))
  else:
   logger.info('{}/{} q5 not answered. No change needed for {}.'.format(reg_count, total_reg, reg._id))

def migrate_registrations_q5_metadata ( schema ) : registrations = Node . find ( ( Q ( 'is_registration' , 'eq' , True ) & Q ( 'registered_schema' , 'eq' , schema ) ) ) total_reg = registrations . count ( ) logger . info ( 'Examining {} registrations for q5 metadata' . format ( total_reg ) ) reg_count = 0 for reg in registrations : reg_count += 1 if reg . registered_meta . get ( schema . _id , { } ) . get ( 'q5' , { } ) . get ( 'value' , { } ) : reg . registered_meta [ schema . _id ] [ 'q5' ] [ 'value' ] = reg . registered_meta [ schema . _id ] [ 'q5' ] [ 'value' ] . rstrip ( ) reg . save ( ) logger . info ( '{}/{} Migrated q5 response for {}' . format ( reg_count , total_reg , reg . _id ) ) else : logger . info ( '{}/{} q5 not answered. No change needed for {}.' . format ( reg_count , total_reg , reg . _id ) )
finds prereg challenge registrations whose registered_meta includes q5 and corrects .