Exemplo n.º 1
0
	def post(self, id):
		comment = Comment.get_by_id(int(id))
		
		if(comment):
			text = self.request.get("text")
			
			if(text is not ""):
				idea_key = Comment.idea.get_value_for_datastore(comment)
				idea = Idea.get(idea_key)
				
				reply = Comment(
					idea = idea_key,
					author = self.current_user.key(),
					reply_to = comment.key(),
					text = text,
				)
				
				reply.put()
				idea.comments += 1
				idea.put()
				
				event = CommentReplyEvent(self.current_user, reply, comment)
				
				values = {
					"response" : "Reply sent",
					"next":{
						"content": "Back",
						"url": "/idea/"+str(idea.key().id())
					}
				}
				path = "feedback.html"
				self.render(path, values)
				
			else:
				raise GetpitchdError("Comment text is empty")
			
		else:
			raise GetpitchdError("Comment does not exist.")