def onCVEAction(self, cve, action, **args): try: if args["current_user"].is_authenticated(): query = {'user': args["current_user"].get_id()} if action == "see": db.p_addToList(self.collectionName, query, "cves", cve) elif action == "unsee": db.p_removeFromList(self.collectionName, query, "cves", cve) elif action == "save_settings": mode = args["fields"]["mode"][0] buttons = args["fields"]["buttons"][0] mark = args["fields"]["mark"][0] filters = args["fields"]["filters"][0] markcolor = args["fields"]["markcolor"][0] if (mode in ["auto", "manual"] and buttons in ["show", "hide"] and mark in ["show", "hide"] and filters in ["show", "hide"] and re.match("^#[0-9A-Fa-f]{6}$", markcolor)): db.p_writeUserSetting(self.collectionName, args["current_user"].get_id(), "mode", mode) db.p_writeUserSetting(self.collectionName, args["current_user"].get_id(), "buttons", buttons) db.p_writeUserSetting(self.collectionName, args["current_user"].get_id(), "mark", mark) db.p_writeUserSetting(self.collectionName, args["current_user"].get_id(), "filters", filters) db.p_writeUserSetting(self.collectionName, args["current_user"].get_id(), "markcolor", markcolor) else: return False return True return False except Exception as e: print(e) return False
def onCVEAction(self, cve, action, **args): try: query = {'user': args["current_user"].get_id()} if action == "bookmark": db.p_addToList(self.collectionName, query, "bookmarks", cve) elif action == "unbookmark": db.p_removeFromList(self.collectionName, query, "bookmarks", cve) return True except Exception as e: return False
def _deleteIfExists(self, cve, user, noteID): note = [x for x in self._getNotesFor(cve, user) if x["id"] == noteID] if note: db.p_removeFromList(self.collectionName, {'cve': cve}, "notes", note[0])