コード例 #1
0
ファイル: edit_handlers.py プロジェクト: mjunaidi/qiita
    def get(self):
        study_title = self.get_argument('study_title', None)
        old_study_title = self.get_argument('old_study_title', None)

        if study_title is None:
            to_write = False
        elif study_title == old_study_title:
            to_write = True
        else:
            to_write = False if Study.exists(study_title) else True

        self.write(str(to_write))
コード例 #2
0
ファイル: edit_handlers.py プロジェクト: yimsea/qiita
    def get(self):
        study_title = self.get_argument('study_title', None)
        old_study_title = self.get_argument('old_study_title', None)

        if study_title is None:
            to_write = False
        elif study_title == old_study_title:
            to_write = True
        else:
            to_write = False if Study.exists(study_title) else True

        self.write(str(to_write))
コード例 #3
0
ファイル: study_handlers.py プロジェクト: gustabf/qiita
    def get(self):
        study_title = self.get_argument('study_title', None)
        old_study_title = self.get_argument('old_study_title', None)

        if study_title is None:
            self.write('False')
            return

        if old_study_title and study_title == old_study_title:
            self.write('True')
            return

        self.write('False' if Study.exists(study_title) else 'True')
コード例 #4
0
ファイル: test_study.py プロジェクト: MarkBruns/qiita
 def test_exists(self):
     self.assertTrue(Study.exists('Identification of the Microbiomes for '
                                  'Cannabis Soils'))
     self.assertFalse(Study.exists('Not Cannabis Soils'))
コード例 #5
0
ファイル: test_study.py プロジェクト: jwdebelius/qiita
 def test_exists(self):
     self.assertTrue(
         Study.exists('Identification of the Microbiomes for '
                      'Cannabis Soils'))
     self.assertFalse(Study.exists('Not Cannabis Soils'))
コード例 #6
0
ファイル: study.py プロジェクト: mestaki/qiita
    def post(self):
        try:
            payload = json_decode(self.request.body)
        except ValueError:
            self.fail('Could not parse body', 400)
            return

        required = {
            'title', 'study_abstract', 'study_description', 'study_alias',
            'owner', 'contacts'
        }

        if not required.issubset(payload):
            self.fail('Not all required arguments provided', 400)
            return

        title = payload['title']
        study_abstract = payload['study_abstract']
        study_desc = payload['study_description']
        study_alias = payload['study_alias']
        notes = payload['notes']

        owner = payload['owner']
        if not User.exists(owner):
            self.fail('Unknown user', 403)
            return
        else:
            owner = User(owner)

        contacts = payload['contacts']

        if Study.exists(title):
            self.fail('Study title already exists', 409)
            return

        pi_name = contacts['principal_investigator'][0]
        pi_aff = contacts['principal_investigator'][1]
        if not StudyPerson.exists(pi_name, pi_aff):
            self.fail('Unknown principal investigator', 403)
            return
        else:
            pi = StudyPerson.from_name_and_affiliation(pi_name, pi_aff)

        lp_name = contacts['lab_person'][0]
        lp_aff = contacts['lab_person'][1]
        if not StudyPerson.exists(lp_name, lp_aff):
            self.fail('Unknown lab person', 403)
            return
        else:
            lp = StudyPerson.from_name_and_affiliation(lp_name, lp_aff)

        info = {
            'lab_person_id': lp,
            'principal_investigator_id': pi,
            'study_abstract': study_abstract,
            'study_description': study_desc,
            'study_alias': study_alias,
            'notes': notes,
            # TODO: we believe it is accurate that mixs is false and
            # metadata completion is false as these cannot be known
            # at study creation here no matter what.
            # we do not know what should be done with the timeseries.
            'mixs_compliant': False,
            'metadata_complete': False,
            'timeseries_type_id': 1
        }
        study = Study.create(owner, title, info)

        self.set_status(201)
        self.write({'id': study.id})
        self.finish()
コード例 #7
0
ファイル: test_study.py プロジェクト: DarcyMyers/qiita
 def test_exists(self):
     self.assertTrue(Study.exists("Identification of the Microbiomes for " "Cannabis Soils"))
     self.assertFalse(Study.exists("Not Cannabis Soils"))