コード例 #1
0
ファイル: idea.py プロジェクト: jamesmwhite/innuvate
	def run(self):
		try:
			person = views.getPerson(self.request)
			if person:
				person.timesViewed = person.timesViewed + 1
				rating = Score.objects(type='view')[0].value
				person.currentRating = person.currentRating + rating
				person.save()
		except Exception as excep:
			print 'error updating ratings in thread '+str(excep)
コード例 #2
0
ファイル: idea_main.py プロジェクト: jamesmwhite/innuvate
def go(request):
	
	tabselected = None
	filtertag = request.META['PATH_INFO']
	if filtertag.find('/idea/') >= 0:
		filtertag = filtertag[6:]
		tabselected = filtertag.replace('/', '')
#		tabselected = 4
	else:
		filtertag = None
		
 	user = request.user
 	
 	rating = None
 	if user.is_authenticated():
		
		person = views.getPerson(request)
	 	if person:
	 		pratings = Rating.objects().order_by('score')
	 		if pratings and len(pratings)>=0:
	 			for prating in pratings:
	 				if person.currentRating >= prating.score:
	 					rating = prating
	 				else:
						break
	 	else:
			person = Person()
			person.email = user.email
			person.name = str(user)
			person.activationdate = datetime.datetime.now()
			person.save()
			views.incrementStat('users',1)
	 		pratings = Rating.objects().order_by('score')
	 		if pratings and len(pratings)>=0:
	 			for prating in pratings:
	 				if person.currentRating >= prating.score:
	 					rating = prating
					else:
						break
 		
 	
	template_values = {
 		'user':user,
 		'tabselected':tabselected,
 		'filtertag':None,
 		'rating':rating,
	}
	path = os.path.join(os.path.dirname(__file__), 'templates/ideas/index.html')
	return render_to_response(path, template_values)