当前位置: 首页>>代码示例>>Python>>正文


Python Project.participants方法代码示例

本文整理汇总了Python中project.models.Project.participants方法的典型用法代码示例。如果您正苦于以下问题:Python Project.participants方法的具体用法?Python Project.participants怎么用?Python Project.participants使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在project.models.Project的用法示例。


在下文中一共展示了Project.participants方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from project.models import Project [as 别名]
# 或者: from project.models.Project import participants [as 别名]
    def create(cls, project_dict, test_mode=False):

        participants = project_dict.pop(u'participants', [])
        vacancies = project_dict.pop(u'vacancies', [])

        if not project_dict.get(u'manager_id'):
            raise Exception(u'No manager ID in creating project')

        # create ID
        if test_mode:
            project_id = project_dict.pop(u'id')
        else:
            project_id = generate_id(21)

        editable_data = Project.get_editable_data(project_dict, update=False)
        editable_data.update(id=project_id)
        project = Project(**editable_data)
        yield project.save(update=False, fields=editable_data.keys())

        participant_ids = []
        for participant in participants:
            participant.update(project_id=project_id)
            participant_id = yield cls.add_participant(participant)
            participant_ids.append(participant_id)

        vacancy_ids = []
        for vacancy in vacancies:
            vacancy.update(project_id=project_id)
            v_id = yield cls.add_vacancy(vacancy)
            vacancy_ids.append(v_id)

        project.participants = participant_ids
        project.vacancies = vacancy_ids

        yield project.save(fields=[u'participants', u'vacancies'])

        scientist = yield Scientist.get_by_id(editable_data[u'manager_id'])
        scientist.managing_project_ids.append(project_id)
        yield scientist.save(fields=[u'managing_project_ids'], columns=[u'managing_project_ids'])
        raise gen.Return(dict(id=project_id))
开发者ID:mayns,项目名称:scienc,代码行数:42,代码来源:project_bl.py


注:本文中的project.models.Project.participants方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。