def post(self, project): note = self.get_argument('note', '') category = self.get_argument('category', '') user = self.get_secure_cookie('user') email = self.get_secure_cookie('email') timestamp = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S') if not note: self.set_status(400) self.finish('<html><body>No project id or note parameters found</body></html>') else: newNote = {'user': user, 'email': email, 'note': note, 'category' : category, 'timestamp': timestamp} p = Project(lims, id=project) p.get(force=True) running_notes = json.loads(p.udf['Running Notes']) if 'Running Notes' in p.udf else {} running_notes[timestamp] = newNote p.udf['Running Notes'] = json.dumps(running_notes) p.put() #saving running notes directly in genstat, because reasons. v=self.application.projects_db.view("project/project_id") for row in v[project]: doc_id=row.value doc=self.application.projects_db.get(doc_id) doc['details']['running_notes']=json.dumps(running_notes) self.application.projects_db.save(doc) self.set_status(201) self.write(json.dumps(newNote))
def post(self, project): user = self.get_secure_cookie('user') email = self.get_secure_cookie('email') a_type = self.get_argument('type', '') title = self.get_argument('title', '') url = self.get_argument('url', '') desc = self.get_argument('desc','') if not a_type or not title: self.set_status(400) self.finish('<html><body>Link title and type is required</body></html>') else: p = Project(lims, id=project) p.get(force=True) links = json.loads(p.udf['Links']) if 'Links' in p.udf else {} links[str(datetime.datetime.now())] = {'user': user, 'email': email, 'type': a_type, 'title': title, 'url': url, 'desc': desc} p.udf['Links'] = json.dumps(links) p.put() self.set_status(200) #ajax cries if it does not get anything back self.set_header("Content-type", "application/json") self.finish(json.dumps(links))
def post(self, project): user = self.get_current_user() a_type = self.get_argument('type', '') title = self.get_argument('title', '') url = self.get_argument('url', '') desc = self.get_argument('desc', '') if not a_type or not title: self.set_status(400) self.finish( '<html><body>Link title and type is required</body></html>') else: p = Project(lims, id=project) p.get(force=True) links = json.loads(p.udf['Links']) if 'Links' in p.udf else {} links[str(datetime.datetime.now())] = { 'user': user.name, 'email': user.email, 'type': a_type, 'title': title, 'url': url, 'desc': desc } p.udf['Links'] = json.dumps(links) p.put() self.set_status(200) #ajax cries if it does not get anything back self.set_header("Content-type", "application/json") self.finish(json.dumps(links))
def make_project_running_note(application, project, note, category, user, email): timestamp = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S') newNote = {'user': user, 'email': email, 'note': note, 'category' : category, 'timestamp': timestamp} p = Project(lims, id=project) p.get(force=True) running_notes = json.loads(p.udf['Running Notes']) if 'Running Notes' in p.udf else {} running_notes.update({timestamp: newNote}) # Saving running note in LIMS p.udf['Running Notes'] = json.dumps(running_notes) p.put() p.get(force=True) #Retry once more if p.udf['Running Notes'] != json.dumps(running_notes): p.udf['Running Notes'] = json.dumps(running_notes) p.put() p.get(force=True) #In the rare case saving to LIMS does not work assert (p.udf['Running Notes'] == json.dumps(running_notes)), "The Running note wasn't saved in LIMS!" #saving running notes directly in genstat, because reasons. v=application.projects_db.view("project/project_id") for row in v[project]: doc_id=row.value doc=application.projects_db.get(doc_id) doc['details']['running_notes']=json.dumps(running_notes) application.projects_db.save(doc) #### Check and send mail to tagged users pattern = re.compile("(@)([a-zA-Z0-9.-]+)") userTags = pattern.findall(note) if userTags: RunningNotesDataHandler.notify_tagged_user(application, userTags, project, note, category, user, timestamp) #### return newNote
def main(lims, args): p=Process(lims, id=args.pid) log=[] datamap={} wsname=None username="******".format(p.technician.first_name, p.technician.last_name) user_email=p.technician.email for art in p.all_inputs(): if len(art.samples)!=1: log.append("Warning : artifact {0} has more than one sample".format(art.id)) for sample in art.samples: #take care of lamda DNA if sample.project: if sample.project.id not in datamap: datamap[sample.project.id]=[sample.name] else: datamap[sample.project.id].append(sample.name) for art in p.all_outputs(): try: wsname=art.location[0].name break except: pass now=datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f") for pid in datamap: pj=Project(lims, id=pid) running_notes=json.loads(pj.udf['Running Notes']) if len(datamap[pid]) > 1: rnt="{0} samples planned for {1}".format(len(datamap[pid]), wsname) else: rnt="{0} sample planned for {1}".format(len(datamap[pid]), wsname) running_notes[now]={"note": rnt, "user" : username, "email":user_email, "category":"Workset"} pj.udf['Running Notes']=json.dumps(running_notes) pj.put() log.append("Updated project {0} : {1}, {2} samples in this workset".format(pid,pj.name, len(datamap[pid]))) with open("EPP_Notes.log", "w") as flog: flog.write("\n".join(log)) for out in p.all_outputs(): #attach the log file if out.name=="RNotes Log": attach_file(os.path.join(os.getcwd(), "EPP_Notes.log"), out) sys.stderr.write("Updated {0} projects successfully".format(len(datamap.keys())))
def post(self, project): note = self.get_argument('note', '') user = self.get_secure_cookie('user') email = self.get_secure_cookie('email') if not note: self.set_status(400) self.finish('<html><body>No project id or note parameters found</body></html>') else: newNote = {'user': user, 'email': email, 'note': note} p = Project(lims, id=project) p.get(force=True) running_notes = json.loads(p.udf['Running Notes']) if 'Running Notes' in p.udf else {} running_notes[str(datetime.datetime.now())] = newNote p.udf['Running Notes'] = json.dumps(running_notes) p.put() self.set_status(201) self.write(json.dumps(newNote))
def make_project_running_note(application, project, note, category, user, email): timestamp = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S') newNote = {'user': user, 'email': email, 'note': note, 'category' : category, 'timestamp': timestamp} p = Project(lims, id=project) p.get(force=True) running_notes = json.loads(p.udf['Running Notes']) if 'Running Notes' in p.udf else {} running_notes.update({timestamp: newNote}) # Saving running note in LIMS p.udf['Running Notes'] = json.dumps(running_notes) p.put() #saving running notes directly in genstat, because reasons. v=application.projects_db.view("project/project_id") for row in v[project]: doc_id=row.value doc=application.projects_db.get(doc_id) doc['details']['running_notes']=json.dumps(running_notes) application.projects_db.save(doc) return newNote
def post(self, project_id): try: data = json.loads(self.request.body) text=data.get('text', '') p=Project(lims, id=project_id) p.udf['Lab Status']=text p.put() view=self.application.projects_db.view("project/project_id") for row in view[project_id]: doc=self.application.projects_db.get(row.id) doc['details']['lab_status']=text self.application.projects_db.save(doc) except Exception as e: self.set_status(400) self.finish('<html><body><p>could not update Entity {} :</p><pre>{}</pre></body></html>'.format( cl_id, e)) else: self.set_status(200) self.set_header("Content-type", "application/json") self.write(self.request.body)
def post(self, project_id): try: data = json.loads(self.request.body) text = data.get('text', '') p = Project(lims, id=project_id) p.udf['Internal Costs'] = text p.put() view = self.application.projects_db.view("project/project_id") for row in view[project_id]: doc=self.application.projects_db.get(row.id) doc['details']['internal_costs']=text self.application.projects_db.save(doc) except Exception as e: self.set_status(400) self.finish('<html><body><p>could not update Entity {} :</p><pre>{}</pre></body></html>'.format( project_id, e)) else: self.set_status(200) self.set_header("Content-type", "application/json") self.write(self.request.body)
def update_project(self, lims_id: str, name: str = None) -> None: """Update information about a project.""" lims_project = Project(self, id=lims_id) if name: lims_project.name = name lims_project.put()
def main(lims, args): p = Process(lims, id=args.pid) log = [] datamap = {} wsname = None username = "******".format(p.technician.first_name, p.technician.last_name) user_email = p.technician.email for art in p.all_inputs(): if len(art.samples) != 1: log.append( "Warning : artifact {0} has more than one sample".format( art.id)) for sample in art.samples: #take care of lamda DNA if sample.project: if sample.project.id not in datamap: datamap[sample.project.id] = [sample.name] else: datamap[sample.project.id].append(sample.name) for art in p.all_outputs(): try: wsname = art.location[0].name break except: pass now = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f") for pid in datamap: pj = Project(lims, id=pid) running_notes = json.loads(pj.udf['Running Notes']) if len(datamap[pid]) > 1: rnt = "{0} samples planned for {1}".format(len(datamap[pid]), wsname) else: rnt = "{0} sample planned for {1}".format(len(datamap[pid]), wsname) running_notes[now] = { "note": rnt, "user": username, "email": user_email, "category": "Workset" } pj.udf['Running Notes'] = json.dumps(running_notes) pj.put() log.append( "Updated project {0} : {1}, {2} samples in this workset".format( pid, pj.name, len(datamap[pid]))) with open("EPP_Notes.log", "w") as flog: flog.write("\n".join(log)) for out in p.all_outputs(): #attach the log file if out.name == "RNotes Log": attach_file(os.path.join(os.getcwd(), "EPP_Notes.log"), out) sys.stderr.write("Updated {0} projects successfully".format( len(datamap.keys())))