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): 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_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 get(self, project): self.set_header("Content-type", "application/json") p = Project(lims, id=project) p.get(force=True) # Sorted running notes, by date running_notes = json.loads(p.udf['Running Notes']) if 'Running Notes' in p.udf else {} sorted_running_notes = OrderedDict() for k, v in sorted(running_notes.iteritems(), key=lambda t: t[0], reverse=True): sorted_running_notes[k] = v self.write(sorted_running_notes)
def get(self, project): self.set_header("Content-type", "application/json") p = Project(lims, id=project) p.get(force=True) links = json.loads(p.udf['Links']) if 'Links' in p.udf else {} #Sort by descending date, then hopefully have deviations on top sorted_links = OrderedDict() for k, v in sorted(links.iteritems(), key=lambda t: t[0], reverse=True): sorted_links[k] = v sorted_links = OrderedDict(sorted(sorted_links.iteritems(), key=lambda (k,v): v['type'])) self.write(sorted_links)
def get(self, project): self.set_header("Content-type", "application/json") p = Project(lims, id=project) p.get(force=True) links = json.loads(p.udf['Links']) if 'Links' in p.udf else {} #Sort by descending date, then hopefully have deviations on top sorted_links = OrderedDict() for k, v in sorted(links.items(), key=lambda t: t[0], reverse=True): sorted_links[k] = v sorted_links = OrderedDict(sorted(sorted_links.items(), key=lambda k: k[1]['type'])) self.write(sorted_links)
def get(self, project): self.set_header("Content-type", "application/json") p = Project(lims, id=project) try: p.get(force=True) except: raise tornado.web.HTTPError(404, reason='Project not found: {}'.format(project)) # self.set_status(404) # self.write({}) else: # Sorted running notes, by date running_notes = json.loads(p.udf['Running Notes']) if 'Running Notes' in p.udf else {} sorted_running_notes = OrderedDict() for k, v in sorted(running_notes.iteritems(), key=lambda t: t[0], reverse=True): sorted_running_notes[k] = v self.write(sorted_running_notes)
def get(self, project): self.set_header("Content-type", "application/json") p = Project(lims, id=project) try: p.get(force=True) except: raise tornado.web.HTTPError(404, reason='Project not found: {}'.format(project)) # self.set_status(404) # self.write({}) else: # Sorted running notes, by date running_notes = json.loads(p.udf['Running Notes']) if 'Running Notes' in p.udf else {} sorted_running_notes = OrderedDict() for k, v in sorted(running_notes.items(), key=lambda t: t[0], reverse=True): sorted_running_notes[k] = v self.write(sorted_running_notes)
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 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