version


# 创建verison
asset_type_entity = sour_version['asset']
# 每一个任务下都有一个asset_entity, 所有版本共用
query_str = ('Asset where name is "{}" '
             'and type.id is "{}" '
             'and parent.id is "{}"').format(
    asset_type_entity['name'],
    asset_type_entity['type']['id'],
    task['parent']['id'])

asset_entity = session.query(query_str).first()

if not asset_entity:
    asset_entity = session.create('Asset', {
        'name': asset_type_entity['name'],
        'type': asset_type_entity['type'],
        'parent': target_task['parent'],
    })
# 获取版本号
version_entity = session.query(
    'AssetVersion where task.id is {} '
    'order by version descending'.format(target_task['id']))
if version_entity:
    version_num = version_entity.first()['version'] + 1
else:
    version_num = 1
version_data = {'version': version_num,
                'asset': asset_entity,
                'task': target_task,
                'comment': u'复制版本,原版本ID:{}'.format(version['id'])
               }

评论
  目录