def POST(self): flagid = self.env["members"][0] flag = fm.flagORM.getByID(flagid) if flag.userID != self.session.id: self.session.pushAlert("You can't delete a flag you don't own!", "Can't do that!", "error") self.head = ("303 SEE OTHER", [("location", "/you/flags")]) return pubFlags = pubfc.userPublicFlagsCollection(self.session.id) privFlags = fc.userFlagsCollection(self.session.id) if flag.visibility: pubFlags.delObject(flag.id) privFlags.delObject(flag.id) flag.delete() su.updateSearch() self.session.pushAlert("Flag `%s` deleted" % flag.title, "Bye!", "warning") self.head = ("303 SEE OTHER", [("location", "/you/flags")])
def POST(self): title = self.env["members"]["title"] if self.env["members"].has_key("title") else None description = self.env["members"]["description"] or "" labels = self.env["members"]["labels"] if self.env["members"].has_key("labels") else "" url = self.env["members"]["url"] if self.env["members"].has_key("url") else "" visibility = True if self.env["members"].has_key("vis") and self.env["members"]["vis"] == "on" else False if not title: self.session.pushAlert("We can't make a flag with no title!", "Whoa there kiddo...", "error") view = flagNewTmpl(searchList=[self.tmplSearchList]) view.titleError = True view.description = description view.labels = labels view.url = url view.vis = visibility return view try: labels = list(set(json.loads(labels))) except: labels = list(set(labels.strip(" ").split(","))) for label in range(len(labels)): labels[label] = mdu.cleanInput(labels[label]) newFlag = fm.flagORM(title=mdu.cleanInput(title), description=description, labels=labels, url=url, userID=self.session.id, visibility=visibility) pubFlags = pubfc.userPublicFlagsCollection(self.session.id) privFlags = fc.userFlagsCollection(self.session.id) if visibility: pubFlags.addObject(newFlag.id) privFlags.addObject(newFlag.id) newFlag.save() su.updateSearch() self.session.pushAlert("Hey look, you've made another flag!", "Horay!", "success") self.head = ("303 SEE OTHER", [("location", str("/flags/view/%s"%newFlag.id))])
def POST(self): flagid = self.env["members"][0] title = self.env["members"]["title"] if self.env["members"].has_key("title") else None description = self.env["members"]["description"] or "" labels = self.env["members"]["labels"] or "" url = self.env["members"]["url"] or "" visibility = True if self.env["members"].has_key("vis") and self.env["members"]["vis"] == "on" else False flag = fm.flagORM.getByID(flagid) if flag.userID != self.session.id: self.head = ("303 SEE OTHER", [("Location", "/flags/view/%s"%flagid)]) self.session.pushAlert("You can't edit someone else's flag! We're working on a cloning feature but until then, just hold tight or copy and paste the flag.", "Hold it!", "error") return if not title: self.session.pushAlert("We can't make a flag with no title!", "Whoa there kiddo...", "error") view = flagEditTmpl(searchList=[self.tmplSearchList]) view.titleError = True view.description = description view.labels = labels view.url = url view.id = flagid view.vis = visibility return view #Will only work if self.env["cfg"].enableDynamicLabels is enabled #otherwise it will fall over to the except try: labels = list(set(json.loads(labels))) except: labels = list(set(labels.replace(" ", "").split(","))) for label in range(len(labels)): labels[label] = mdu.cleanInput(labels[label]) flag.title = mdu.cleanInput(title) flag.description = description flag.labels = labels flag.url = url if flag.visibility != visibility: pubFlags = pubfc.userPublicFlagsCollection(self.session.id) if visibility: pubFlags.addObject(flag.id) else: pubFlags.delObject(flag.id) flag.visibility = visibility flag.created = datetime.now() flag.save() su.updateSearch() self.session.pushAlert("The flag `%s` has been updated"%flag.title, "Yay!", "success") self.head = ("303 SEE OTHER", [("location", str("/flags/view/%s"%flag.id))])