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


Python Project.get_json_by_id方法代码示例

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


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

示例1: get_my_projects

# 需要导入模块: from project.models import Project [as 别名]
# 或者: from project.models.Project import get_json_by_id [as 别名]
    def get_my_projects(cls, manager_id):
        scientist_columns = [u'managing_project_ids']
        scientist_json = yield Scientist.get_json_by_id(manager_id, columns=scientist_columns)

        # [{scientist_id, vacancy_id, message}]
        project_ids = scientist_json.get(u'managing_project_ids', [])
        if not project_ids:
            raise gen.Return([])

        projects = []
        for project_id in project_ids:
            project_columns = [u'title', u'responses']
            project_json = yield Project.get_json_by_id(project_id, columns=project_columns)
            project_json.update(project_id=project_id)
            raw_responses = project_json.pop(u'responses', [])

            if not raw_responses:
                project_json.update(responses=[])
                projects.append(project_json)
                continue

            responses = []

            for response in raw_responses:
                response_data = yield cls.get_response_data(response)
                responses.append(response_data)
            project_json.update(responses=responses)

            projects.append(project_json)
        raise gen.Return(projects)
开发者ID:mayns,项目名称:scienc,代码行数:32,代码来源:scientist_bl.py

示例2: get

# 需要导入模块: from project.models import Project [as 别名]
# 或者: from project.models.Project import get_json_by_id [as 别名]
    def get(cls, project_id):
        project_data = yield Project.get_json_by_id(project_id)
        vacancies = []
        participants = []

        for vacancy_id in project_data.get(u'vacancies', []):
            vacancy = yield cls.get_vacancy(vacancy_id)
            vacancies.append(vacancy)
        for p_id in project_data.get(u'participants', []):
            p = yield cls.get_participant(p_id)
            participants.append(p)

        project_data.update(
            vacancies=vacancies,
            participants=participants
        )
        raise gen.Return(project_data)
开发者ID:mayns,项目名称:scienc,代码行数:19,代码来源:project_bl.py

示例3: get_participation_projects

# 需要导入模块: from project.models import Project [as 别名]
# 或者: from project.models.Project import get_json_by_id [as 别名]
    def get_participation_projects(cls, scientist_id):
        cols = [u'participating_projects']
        sc_json = yield Scientist.get_json_by_id(scientist_id, columns=cols)
        # [{project_id, role_id}]

        projects = []
        for participation in sc_json.get(u'participating_projects', []):
            project_columns = [u'title', u'participants']
            project_data = yield Project.get_json_by_id(participation[u'project_id'], columns=project_columns)
            participants = project_data.pop(u'participants')
            project_data.update(project_id=participation[u'project_id'],
                                role_name=[k[u'role_name'] for k in participants if k[u'id'] == participation[u'role_id']][0]
            )

            projects.append(project_data)
        print projects
        raise gen.Return(projects)
开发者ID:mayns,项目名称:scienc,代码行数:19,代码来源:scientist_bl.py

示例4: get_desired_projects

# 需要导入模块: from project.models import Project [as 别名]
# 或者: from project.models.Project import get_json_by_id [as 别名]
    def get_desired_projects(cls, scientist_id):
        cols = [u'desired_vacancies']
        sc_json = yield Scientist.get_json_by_id(scientist_id, columns=cols)

        # [{project_id, vacancy_id}]
        projects = []
        for application in sc_json(u'desired_vacancies', []):
            project_columns = [u'title', u'vacancies']
            project_data = yield Project.get_json_by_id(application[u'project_id'], columns=project_columns)

            vacancies = project_data.pop(u'vacancies', [])
            project_data.update(project_id=application[u'project_id'],
                                vacancy_id=application[u'vacancy_id'],
                                vacancy_name=[k[u'vacancy_name'] for k in vacancies if
                                              k[u'id'] == application[u'vacancy_id']][0]
            )

            projects.append(project_data)
        print projects
        raise gen.Return(projects)
开发者ID:mayns,项目名称:scienc,代码行数:22,代码来源:scientist_bl.py


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