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


Python StudyPerson.create方法代码示例

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


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

示例1: test_create_studyperson

# 需要导入模块: from qiita_db.study import StudyPerson [as 别名]
# 或者: from qiita_db.study.StudyPerson import create [as 别名]
 def test_create_studyperson(self):
     new = StudyPerson.create('SomeDude', '[email protected]', 'affil',
                              '111 fake street', '111-121-1313')
     self.assertEqual(new.id, 4)
     obs = self.conn_handler.execute_fetchall(
         "SELECT * FROM qiita.study_person WHERE study_person_id = 4")
     self.assertEqual(obs, [[4, 'SomeDude', '[email protected]', 'affil',
                      '111 fake street', '111-121-1313']])
开发者ID:MarkBruns,项目名称:qiita,代码行数:10,代码来源:test_study.py

示例2: post

# 需要导入模块: from qiita_db.study import StudyPerson [as 别名]
# 或者: from qiita_db.study.StudyPerson import create [as 别名]
    def post(self, *args, **kwargs):
        name = self.get_argument('name')
        affiliation = self.get_argument('affiliation')
        email = self.get_argument('email')

        phone = self.get_argument('phone', None)
        address = self.get_argument('address', None)

        if StudyPerson.exists(name, affiliation):
            self.fail('Person already exists', 409)
            return

        p = StudyPerson.create(name=name, affiliation=affiliation, email=email,
                               phone=phone, address=address)

        self.set_status(201)
        self.write({'id': p.id})
        self.finish()
开发者ID:ElDeveloper,项目名称:qiita,代码行数:20,代码来源:study_person.py

示例3: _get_study_person_id

# 需要导入模块: from qiita_db.study import StudyPerson [as 别名]
# 或者: from qiita_db.study.StudyPerson import create [as 别名]
    def _get_study_person_id(self, index, new_people_info):
        """Returns the id of the study person, creating if needed

        If index < 0, means that we need to create a new study person, and its
        information is stored in new_people_info[index]

        Parameters
        ----------
        index : int
            The index of the study person
        new_people_info : list of tuples
            The information of the new study persons added through the
            interface

        Returns
        -------
        int
            the study person id
        """
        # If the ID is less than 0, then this is a new person
        if index < 0:
            return StudyPerson.create(*new_people_info[index]).id

        return index
开发者ID:yimsea,项目名称:qiita,代码行数:26,代码来源:edit_handlers.py

示例4: setUp

# 需要导入模块: from qiita_db.study import StudyPerson [as 别名]
# 或者: from qiita_db.study.StudyPerson import create [as 别名]
 def setUp(self):
     StudyPerson.create('SomeDude', '[email protected]', 'some',
                        '111 fake street', '111-121-1313')
     User.create('[email protected]', 'password')
     self.config1 = CONFIG_1
     self.config2 = CONFIG_2
开发者ID:Jorge-C,项目名称:qiita,代码行数:8,代码来源:test_commands.py

示例5: test_create_studyperson_already_exists

# 需要导入模块: from qiita_db.study import StudyPerson [as 别名]
# 或者: from qiita_db.study.StudyPerson import create [as 别名]
 def test_create_studyperson_already_exists(self):
     obs = StudyPerson.create('LabDude', '[email protected]', 'knight lab')
     self.assertEqual(obs.name, 'LabDude')
     self.assertEqual(obs.email, '[email protected]')
开发者ID:MarkBruns,项目名称:qiita,代码行数:6,代码来源:test_study.py

示例6: post

# 需要导入模块: from qiita_db.study import StudyPerson [as 别名]
# 或者: from qiita_db.study.StudyPerson import create [as 别名]
    def post(self, study=None):
        the_study = None
        form_factory = StudyEditorExtendedForm
        if study:
            # Check study and user access
            the_study = self._check_study_exists_and_user_access(study)
            # If the study is public, we use the short version of the form
            if the_study.status == 'public':
                form_factory = StudyEditorForm

        # Get the form data from the request arguments
        form_data = form_factory()
        form_data.process(data=self.request.arguments)

        # Get information about new people that need to be added to the DB
        new_people_info = zip(self.get_arguments('new_people_names'),
                              self.get_arguments('new_people_emails'),
                              self.get_arguments('new_people_affiliations'),
                              self.get_arguments('new_people_phones'),
                              self.get_arguments('new_people_addresses'))

        # New people will be indexed with negative numbers, so we reverse
        # the list here
        new_people_info.reverse()

        index = int(form_data.data['principal_investigator'][0])
        if index < 0:
            # If the ID is less than 0, then this is a new person
            PI = StudyPerson.create(
                new_people_info[index][0],
                new_people_info[index][1],
                new_people_info[index][2],
                new_people_info[index][3] or None,
                new_people_info[index][4] or None).id
        else:
            PI = index

        if form_data.data['lab_person'][0]:
            index = int(form_data.data['lab_person'][0])
            if index < 0:
                # If the ID is less than 0, then this is a new person
                lab_person = StudyPerson.create(
                    new_people_info[index][0],
                    new_people_info[index][1],
                    new_people_info[index][2],
                    new_people_info[index][3] or None,
                    new_people_info[index][4] or None).id
            else:
                lab_person = index
        else:
            lab_person = None

        # TODO: Get the portal type from... somewhere
        # TODO: MIXS compliant?  Always true, right?
        info = {
            'portal_type_id': 1,
            'lab_person_id': lab_person,
            'principal_investigator_id': PI,
            'metadata_complete': False,
            'mixs_compliant': True,
            'study_description': form_data.data['study_description'][0],
            'study_alias': form_data.data['study_alias'][0],
            'study_abstract': form_data.data['study_abstract'][0]}

        if 'timeseries' in form_data.data and form_data.data['timeseries']:
            info['timeseries_type_id'] = form_data.data['timeseries'][0]

        study_title = form_data.data['study_title'][0]

        if the_study:
            # We are under editing, so just update the values
            the_study.title = study_title
            the_study.info = info

            msg = ('Study <a href="/study/description/%d">%s</a> '
                   'successfully updated' %
                   (the_study.id, form_data.data['study_title'][0]))
        else:
            # create the study
            # TODO: Fix this EFO once ontology stuff from emily is added
            the_study = Study.create(User(self.current_user), study_title,
                                     efo=[1], info=info)

            msg = ('Study <a href="/study/description/%d">%s</a> '
                   'successfully created' %
                   (the_study.id, form_data.data['study_title'][0]))

        # Add the environmental packages
        if ('environmental_packages' in form_data.data and
                form_data.data['environmental_packages']):
            the_study.environmental_packages = form_data.data[
                'environmental_packages']

        if form_data.data['pubmed_id'][0]:
            # The user can provide a comma-seprated list
            pmids = form_data.data['pubmed_id'][0].split(',')
            # Make sure that we strip the spaces from the pubmed ids
            the_study.pmids = [pmid.strip() for pmid in pmids]

        self.render('index.html', message=msg, level='success',
#.........这里部分代码省略.........
开发者ID:gustabf,项目名称:qiita,代码行数:103,代码来源:study_handlers.py

示例7: test_create_studyperson

# 需要导入模块: from qiita_db.study import StudyPerson [as 别名]
# 或者: from qiita_db.study.StudyPerson import create [as 别名]
 def test_create_studyperson(self):
     new = StudyPerson.create("SomeDude", "[email protected]", "affil", "111 fake street", "111-121-1313")
     self.assertEqual(new.id, 4)
     obs = self.conn_handler.execute_fetchall("SELECT * FROM qiita.study_person WHERE study_person_id = 4")
     self.assertEqual(obs, [[4, "SomeDude", "[email protected]", "affil", "111 fake street", "111-121-1313"]])
开发者ID:DarcyMyers,项目名称:qiita,代码行数:7,代码来源:test_study.py


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