Beispiel #1
0
def new_comment(request,idnum):
	try:
		post = request.POST
		sentiment = post["sentiment"]	
		title = post["comment_title"]
		text = post["comment_text"]
		all = post["images"]
		images = map(int,post["images"].split("_")) if all else []
		venue = Venue.objects.get(id=idnum)
		if sentiment and title and text:
			comment = Comment()
			comment.set_sentiment_by_index(int(sentiment))
			comment.title = title
			comment.text = text
			comment.venue = venue
			comment.user = request.user
			comment.save()
			for id in images:
				image = VenueImage.objects.get(id=id)
				image.comment = comment
				image.save()
		else:
			raise Exception("invalid post content")
	except Exception, e:
		pass