本文整理汇总了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']])
示例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()
示例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
示例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
示例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]')
示例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',
#.........这里部分代码省略.........
示例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"]])