def post(self, *args, **kwargs): ''' AJAX // Delete a paste object from the database ''' paste_uuid = self.get_argument("uuid", "") paste = PasteBin.by_uuid(paste_uuid) user = self.get_current_user() if paste is not None and paste.team_id == user.team.id: dbsession.delete(paste) dbsession.flush() self.redirect("/user/share/pastebin")
def get(self, *args, **kwargs): ''' AJAX // Delete a paste object from the database ''' form = Form(paste_uuid="Paste does not exist.", ) if form.validate(self.request.arguments): paste_uuid = self.get_argument("paste_uuid") paste = PasteBin.by_uuid(paste_uuid) user = self.get_current_user() if paste is not None and paste.team_id == user.team.id: dbsession.delete(paste) dbsession.flush() self.redirect("/user/share/pastebin")
def get(self, *args, **kwargs): ''' AJAX // Delete a paste object from the database ''' form = Form( paste_uuid="Paste does not exist.", ) if form.validate(self.request.arguments): paste_uuid = self.get_argument("paste_uuid") paste = PasteBin.by_uuid(paste_uuid) user = self.get_current_user() if paste is not None and paste.team_id == user.team.id: dbsession.delete(paste) dbsession.flush() self.redirect("/user/share/pastebin")
def get(self, *args, **kwargs): ''' AJAX // Retrieves a paste from the database ''' form = Form( paste_uuid="Paste does not exist.", ) if form.validate(self.request.arguments): paste_uuid = self.get_argument("paste_uuid") user = self.get_current_user() paste = PasteBin.by_uuid(paste_uuid) if paste is None or paste.team_id != user.team.id: self.render("pastebin/display.html", errors=["Paste does not exist."], paste=None) else: self.render("pastebin/display.html", errors=None, paste=paste) else: self.render("pastebin/display.html", errors=form.errors, paste=None)
def post(self, *args, **kwargs): ''' Creates a new text share ''' form = Form( name="Please enter a name", content="Please provide some content", ) if form.validate(self.request.arguments): user = self.get_current_user() paste = PasteBin(name=unicode(self.get_argument("name")), contents=unicode(self.get_argument("content")), team_id=user.team.id) dbsession.add(paste) dbsession.flush() self.event_manager.paste_bin(user, paste) self.redirect('/user/share/pastebin')
def post(self, *args, **kwargs): ''' Creates a new text share ''' name = self.get_argument("name", "") content = self.get_argument("content", "") if 0 < len(name) and 0 < len(content): user = self.get_current_user() paste = PasteBin( name=unicode(name), contents=unicode(content), team_id=user.team.id ) dbsession.add(paste) dbsession.flush() event = self.event_manager.create_paste_bin_event(user, paste) self.new_events.append(event) self.redirect('/user/share/pastebin')