Пример #1
0
	def put(self):
		JSON = json.loads(json.dumps(request.get_json(force = True)))
		url = JSON['url']
		userID = current_user.email
		name = current_user.name
		content = JSON['content']
		time = str(datetime.datetime.now())
		comment = Comment(ID = userID, name = name, content = content, time = time)
		check = mongo.db.comments.find({'_id': url})
		if check.count() > 0:
			mongo.db.comments.update({'_id': url}, {'$push': {'comments': comment.toDict()}})
		else:
			mongo.db.comments.insert({'_id': url, 'comments': [comment.toDict()]})
		return {'SUCCESS': 'New Comment Updated'}