本文整理汇总了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))