def prep_template_delete_req(prep_id, user_id): """Delete the prep template Parameters ---------- prep_id : int The prep template to update user_id : str The current user object id Returns ------- dict of str {'status': status, 'message': message} """ exists = _check_prep_template_exists(int(prep_id)) if exists['status'] != 'success': return exists prep = PrepTemplate(int(prep_id)) access_error = check_access(prep.study_id, user_id) if access_error: return access_error msg = '' status = 'success' try: PrepTemplate.delete(prep.id) except Exception as e: msg = ("Couldn't remove prep template: %s" % str(e)) status = 'error' return {'status': status, 'message': msg}
def prep_template_delete_req(prep_id, user_id): """Delete the prep template Parameters ---------- prep_id : int The prep template to update user_id : str The current user object id Returns ------- dict of str {'status': status, 'message': message} """ exists = _check_prep_template_exists(int(prep_id)) if exists['status'] != 'success': return exists prep = PrepTemplate(int(prep_id)) access_error = check_access(prep.study_id, user_id) if access_error: return access_error msg = '' status = 'success' try: PrepTemplate.delete(prep.id) except Exception as e: msg = str(e) status = 'error' return {'status': status, 'message': msg}
def delete_prep_template(self, study, user, callback): """Delete the selected prep template Parameters ---------- study : Study The current study object user : User The current user object callback : function The callback function to call with the results once the processing is done """ prep_template_id = int(self.get_argument('prep_template_id')) prep_id = prep_template_id try: PrepTemplate.delete(prep_template_id) msg = ("Prep template %d has been deleted" % prep_template_id) msg_level = "success" prep_id = None except Exception as e: msg = ("Couldn't remove prep template: %s" % str(e)) msg_level = "danger" callback((msg, msg_level, 'prep_template_tab', prep_id, None))
def delete_prep_template(self, study, user, callback): """Delete the selected prep template Parameters ---------- study : Study The current study object user : User The current user object callback : function The callback function to call with the results once the processing is done """ prep_template_id = int(self.get_argument('prep_template_id')) prep_id = prep_template_id try: PrepTemplate.delete(prep_template_id) msg = ("Prep template %d has been deleted" % prep_template_id) msg_level = "success" prep_id = None except Exception as e: msg = ("Couldn't remove prep template: %s" % str(e)) msg_level = "danger" callback((msg, msg_level, 'prep_template_tab', prep_id, None))
def tearDown(self): for fp in self._clean_up_files: if exists(fp): remove(fp) study_id = self.new_study.id for pt in self.new_study.prep_templates(): PrepTemplate.delete(pt.id) if SampleTemplate.exists(study_id): SampleTemplate.delete(study_id) Study.delete(study_id)
def tearDown(self): for fp in self._clean_up_files: if exists(fp): remove(fp) study_id = self.new_study.id for pt in self.new_study.prep_templates(): PrepTemplate.delete(pt.id) if SampleTemplate.exists(study_id): SampleTemplate.delete(study_id) Study.delete(study_id)