def post(self,reactionId): blogReaction= WeblogReactions.get_by_id(int(reactionId)) if(blogReaction is not None): db.delete(blogReaction) util.flushRecentReactions() self.redirect('/'+blogReaction.weblog.relative_permalink()) return
def post(self): blogId_ = self.request.get('blogId') blog= Weblog.get_by_id(int(blogId_)) if(blog is None): self.redirect('/') return blogReaction = WeblogReactions() blogReaction.weblog = blog blogReaction.content = self.request.get('text_input') blogReaction.authorWebsite = self.request.get('website') blogReaction.authorEmail = self.request.get('mail') blogReaction.user = self.request.get('name_input') cpedialog = util.getCPedialog() clientIp = self.request.remote_addr if(cpedialog.recaptcha_enable): challenge = self.request.get('recaptcha_challenge_field') response = self.request.get('recaptcha_response_field') cResponse = captcha.submit( challenge, response, cpedialog.recaptcha_private_key, clientIp) if not cResponse.is_valid: captchahtml = None captchahtml = captcha.displayhtml( public_key = cpedialog.recaptcha_public_key, use_ssl = False, error = cResponse.error_code) reactions = db.GqlQuery("select * from WeblogReactions where weblog =:1 order by date", blog) template_values = { 'blog': blog, 'reactions': reactions, 'blogReaction': blogReaction, 'captchahtml': captchahtml, } self.generate('blog_view.html',template_values) return True user = users.get_current_user() # [Add] not login is no add reaction if not user: self.redirect('/'+blog.relative_permalink()) return if user is not None: blogReaction.author = user blogReaction.authorEmail = str(user.email()) blogReaction.user = str(user.nickname()) blogReaction.userIp = clientIp blogReaction.save() util.flushRecentReactions() self.redirect('/'+blog.relative_permalink()) return