def get_info(self, portal="QIITA"): # Add the portals and, optionally, checkbox to the information studies = [s.id for s in Portal(portal).get_studies()] if not studies: return [] study_info = Study.get_info(studies, info_cols=self.study_cols) info = [] for s in study_info: # Make sure in correct order hold = dict(s) hold['portals'] = ', '.join(sorted(Study(s['study_id'])._portals)) info.append(hold) return info
def post(self): self.check_admin() portal = self.get_argument('portal') studies = map(int, self.get_arguments('selected')) action = self.get_argument('action') try: portal = Portal(portal) except Exception: raise HTTPError(400, reason="Not valid portal: %s" % portal) try: with warnings.catch_warnings(record=True) as warns: if action == "Add": portal.add_studies(studies) elif action == "Remove": portal.remove_studies(studies) else: raise HTTPError(400, reason="Unknown action: %s" % action) except QiitaDBError as e: self.write(action.upper() + " ERROR:<br/>" + str(e)) return msg = '; '.join([str(w.message) for w in warns]) self.write(action + " completed successfully<br/>" + msg)