Ejemplo n.º 1
0
def saveMoviesToDB(results):
	for movie in results:
		try:
			m = Movie.objects.get(title=movie["title"])
		except Exception, e:
			# if not in db, save it
			m = Movie(title=movie["title"], poster_path=movie["poster_path"])
			m.save()
Ejemplo n.º 2
0
def getComments(movieName):
	#Comment.objects.all().delete()
	comments = []
	try:
		movie = Movie.objects.get(title=movieName)
	except Exception, e:
		movie = Movie(title=movieName)
		movie.save()
Ejemplo n.º 3
0
def addMovieForUser(username, movieName):
	'''
		if already liked this movie, unlike it (delete it from the db)
	'''
	user = User.objects.get(username = username)
	try:
		movie = Movie.objects.get(title=movieName)
	except Exception, e:
		movie = Movie(title=movieName)
		movie.save()
Ejemplo n.º 4
0
def addCommentForUser(username, movieName, comment):
	try:
		movie = Movie.objects.get(title=movieName)
	except Exception, e:
		movie = Movie(title=movieName)
		movie.save()