def alert(self, view, frame, message): #print message m = re.search("^(\w+):([^_]+)_(\d+)(_(.*))?", message) if (m != None): action = m.group(1) id = m.group(3) #print "Action", action, " id", id if (action == "EDIT"): note = Note.get(Note.id==id) self.editNote(note) if (action == "ADDTAG"): self.addTag(id, m.group(5)) if (action == "REMOVETAG"): self.removeTag(id, m.group(5)) if (action == "ADDNOTE"): self.newNote(None) pass if (action == "ADDBASKET"): self.addBasket(m.group(2)) if (action == "ADDDROPPEDNOTE"): self.addDroppedNote(message[int(m.start(5)):]) if (action == "SELECTBASKET"): self.selectBasket(m.group(5)) if (action == "DELETENOTE"): self.deleteNote(id) if (action == "SEARCH_TEXT"): self.searchText(m.group(5)) return True else: return False
def addTag(self, noteId, strTag): count = Tag.select().where(Tag.tag == strTag).count() if (count == 0): dbTag = Tag() dbTag.creationDate = dbTag.modificationDate = datetime.date.today() dbTag.tag = strTag dbTag.save() else: dbTag = Tag.get(Tag.tag == strTag) note = Note.get(Note.id == noteId) noteTag = NoteTag() noteTag.note = note noteTag.tag = dbTag noteTag.creationDate = noteTag.modificationDate = datetime.date.today() noteTag.save() self.view.execute_script("notesMD.tags = " + RuntimeSettings.getTags())
def deleteNote(self, id): note = Note.get(Note.id == id) note.delete_instance() for noteTag in NoteTag.select().where(NoteTag.note == id): noteTag.delete_instance() self.reload()