Exemplo n.º 1
0
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)
Exemplo n.º 2
0
def go(request):
	user = request.user
				
	scores = None
	#articles = Article.objects(reported=True)
	scores = Score.objects()
	ratings = Rating.objects()
	
	
	template_values = {
		'scores': scores,
		'user' : user,
		'ratings':ratings,
	}

	path = os.path.join(os.path.dirname(__file__), 'templates/ideas/managescores.html')
	return render_to_response(path, template_values)
Exemplo n.º 3
0
def go(request):
	user = request.user
	rating = None
	if user.is_authenticated():
		people = Person.objects(email=request.user.email)
		if people and len(people)>0:
			person = people[0]			
		 	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
		 					break
	
	template_values = {		
		'user' : user,
		'person' : person,
		'rating' : rating,
	}

	path = os.path.join(os.path.dirname(__file__), 'templates/ideas/mystats.html')
	return render_to_response(path, template_values)
Exemplo n.º 4
0
def initialiseRatings():
	rating = Rating.objects(name='Squire')
	if not rating:
		rating = Rating()
		rating.score = 0
		rating.name = 'Squire'
		rating.image = '/media/images/squire.png'
		rating.save()
	
	rating = Rating.objects(name='Baron')
	if not rating:
		rating = Rating()
		rating.score = 1000
		rating.name = 'Baron'
		rating.image = '/media/images/baron.png'
		rating.save()
	
	rating = Rating.objects(name='Count')
	if not rating:
		rating = Rating()
		rating.score = 1500
		rating.name = 'Count'
		rating.image = '/media/images/count.png'
		rating.save()
		
	rating = Rating.objects(name='Duke')
	if not rating:
		rating = Rating()
		rating.score = 3000
		rating.name = 'Duke'
		rating.image = '/media/images/duke.png'
		rating.save()
		
	rating = Rating.objects(name='Prince')
	if not rating:
		rating = Rating()
		rating.score = 5000
		rating.name = 'Prince'
		rating.image = '/media/images/prince.png'
		rating.save()
		
	rating = Rating.objects(name='Archduke')
	if not rating:
		rating = Rating()
		rating.score = 6000
		rating.name = 'Archduke'
		rating.image = '/media/images/archduke.png'
		rating.save()
		
	rating = Rating.objects(name='Grand Duke')
	if not rating:
		rating = Rating()
		rating.score = 7000
		rating.name = 'Grand Duke'
		rating.image = '/media/images/grandduke.png'
		rating.save()
		
	rating = Rating.objects(name='Viceroy')
	if not rating:
		rating = Rating()
		rating.score = 8000
		rating.name = 'Viceroy'
		rating.image = '/media/images/viceroy.png'
		rating.save()
		
	rating = Rating.objects(name='King')
	if not rating:
		rating = Rating()
		rating.score = 9000
		rating.name = 'King'
		rating.image = '/media/images/king.png'
		rating.save()
		
	rating = Rating.objects(name='Emperor')
	if not rating:
		rating = Rating()
		rating.score = 10000
		rating.name = 'Emperor'
		rating.image = '/media/images/emperor.png'
		rating.save()