def format_history(histories): history_list = [] trans = MigrateDal.get_isp_trans() for history in histories: history_list.append({ 'id': history.id, 'migrate_rooms': sorted(json.loads(history.migrate_rooms)), 'dst_rooms': sorted(json.loads(history.dst_rooms)), 'migrate_isps': sorted([trans[isp] for isp in json.loads(history.migrate_isps)]), 'cur': history.cur, 'all': history.all, 'state': history.state, 'rtx_id': history.rtx_id, 'update_at': history.updated_time.strftime('%Y-%m-%d %H:%M:%S') }) return history_list
def get_previewinfo(): trans = MigrateDal.get_isp_trans() domain_count = ViewRecordDal.zone_domain_count() migrate_list = [] histories = MigrateDal.get_migrated_history() for history in histories: migrate_list.append({ 'migrate_rooms': sorted(json.loads(history.migrate_rooms)), 'dst_rooms': sorted(json.loads(history.dst_rooms)), 'migrate_isps': sorted([trans[isp] for isp in json.loads(history.migrate_isps)]) }) migrate_acl_subnet = ViewIspAclDal.get_migrate_subnet() return {'domain_count': domain_count, 'migrate': migrate_list, 'acl_migrate': migrate_acl_subnet}