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))
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')
def test_exists(self): self.assertTrue(Study.exists('Identification of the Microbiomes for ' 'Cannabis Soils')) self.assertFalse(Study.exists('Not Cannabis Soils'))
def test_exists(self): self.assertTrue( Study.exists('Identification of the Microbiomes for ' 'Cannabis Soils')) self.assertFalse(Study.exists('Not Cannabis Soils'))
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()
def test_exists(self): self.assertTrue(Study.exists("Identification of the Microbiomes for " "Cannabis Soils")) self.assertFalse(Study.exists("Not Cannabis Soils"))