def post(self): loluser = helper.loluser_by_google_user_id(users.get_current_user().user_id()) if not helper.check_for_loluser(self): return if self.request.get('key'): book = db.get(db.Key(self.request.get("key"))) if not book: self.redirect("/notfound") return if book.userid != loluser.id: self.redirect("/accessdenied") return else: book = Book() book.userid = loluser.id book.author = self.request.get("author") book.title = self.request.get("title") try: book.total_pages = int(self.request.get("total_pages")) except ValueError: pass try: book.current_page = int(self.request.get("current_page")) except ValueError: pass try: book.year = int(self.request.get("year")) except ValueError: pass book.put() self.redirect("/books/" + str(loluser.id))
def get(self): loluser = helper.loluser_by_google_user_id(users.get_current_user().user_id()) if not helper.check_for_loluser(self): return book = db.get(db.Key(self.request.get("key"))) if (book.userid != loluser.id): self.redirect("/accessdenied") return book.delete() self.redirect("/books/" + str(loluser.id))
def get(self): loluser = helper.loluser_by_google_user_id(users.get_current_user().user_id()) if not helper.check_for_loluser(self): return try: post = db.get(db.Key(self.request.get("key"))) except BadKeyError: self.redirect('/notfound') return if not helper.check_for_existence_and_ownership(post, self): return post.delete() self.redirect("/blog/" + str(loluser.id))
def get(self): user = users.get_current_user() loluser = helper.loluser_by_google_user_id(user.user_id()) if not helper.check_for_loluser(self): return if self.request.get('key'): try: post = db.get(db.Key(self.request.get("key"))) except BadKeyError: self.redirect('/notfound') return if not helper.check_for_existence_and_ownership(post, self): return values = { 'post' : post } else: values = {} values.update(helper.values(self.request.uri)) path = os.path.join(os.path.dirname(__file__), 'html/editpost.html') self.response.out.write(template.render(path, values))
def get(self): loluser = helper.loluser_by_google_user_id(users.get_current_user().user_id()) if not helper.check_for_loluser(self): return if self.request.get('key'): book = db.get(db.Key(self.request.get("key"))) if not book: self.redirect("/notfound") return if book.userid != loluser.id: self.redirect("/accessdenied") return values = { 'book' : book } else: values = {} values.update(helper.values(self.request.uri)) path = os.path.join(os.path.dirname(__file__), 'html/editbook.html') self.response.out.write(template.render(path, values))
def post(self): loluser = helper.loluser_by_google_user_id(users.get_current_user().user_id()) if not helper.check_for_loluser(self): return if self.request.get('key'): try: post = db.get(db.Key(self.request.get("key"))) except BadKeyError: self.redirect('/notfound') return if not helper.check_for_existence_and_ownership(post, self): return else: post = Post() post.userid = loluser.id maxPost = Post.all().order("-id").get() if not maxPost or not maxPost.id: post.id = 1 else: post.id = maxPost.id + 1 post.title = self.request.get("title") post.content = self.request.get("content") post.put() self.redirect("/blog/" + str(loluser.id))