Exemplo n.º 1
0
	def post(self, id):
		idea = Idea.get_by_id(int(id))	
		
		if(idea):
			author_key = Idea.author.get_value_for_datastore(idea)
			
			if(author_key == self.current_user.key() or self.admin):
				validated, title, answers = Idea.validate(self.request, idea)
		
				if not validated:
					self.redirect("/idea/"+str(idea.key().id())+"/edit")
				else:
					idea.title = title
					idea.answers = answers
					idea.put()
			
					values = {
						"response": "Idea updated",
						"next": {
							"content": "Back",
							"url": "/idea/"+str(idea.key().id()),
						}
					}
					path = "feedback.html"		
					self.render(path, values)
					
			else:
				raise GetpitchdError("Not authorized to edit idea")

		else:
			raise GetpitchdError("Idea does not exist")
Exemplo n.º 2
0
	def post(self):
		validated, title, answers = Idea.validate(self.request)
		
		if not validated:
			self.redirect("/idea/pitch")
		else:
			# Record the idea and redirect to homepage
			idea = Idea(
				title = title,
				author = self.current_user.key(),
				answers = answers,
				version = Idea.get_current_version(),
				country = self.current_user.country,
			)
			idea.put()
			
			user = self.current_user
			user.ideas += 1
			user.put()
			
			text = "I just pitched a new startup idea on @gopitchme: " + idea.title
			url = config.SITE_URL + "/idea/" + str(idea.key().id())
			tweet = generate_tweet(text, url)
			
			response = "Idea pitched"
			call_to_action = "Now, tweet your friends about it!"
			
			values = {
				"response": response,
				"call_to_action": call_to_action,
				"tweet": tweet,
				"skip_url": "/idea/"+str(idea.key().id()),
			}
			path = "idea/tweet.html"
			self.render(path, values)