当前位置: 首页>>代码示例>>Python>>正文


Python Score.objects方法代码示例

本文整理汇总了Python中models.Score.objects方法的典型用法代码示例。如果您正苦于以下问题:Python Score.objects方法的具体用法?Python Score.objects怎么用?Python Score.objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Score的用法示例。


在下文中一共展示了Score.objects方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: submitidea

# 需要导入模块: from models import Score [as 别名]
# 或者: from models.Score import objects [as 别名]
def submitidea(request):
	error_msg = u"No POST data sent."	
	if request.method == "POST":
		post = request.POST.copy()
		if post.has_key('tags') and post.has_key('title') and post.has_key('content'):
			try:
				content = post['content']
				idea = Idea()
				idea.tags = post['tags'].strip().split(',')
				idea.author = str(request.user)
				print "user: "+str(request.user)
				idea.email = str(request.user.email)
				idea.title = post['title']
				idea.votecount = 0
				idea.viewcount = 0
				idea.content = content
				if idea.content and idea.title and idea.author:
					try:
						person = getPerson(request)
						person.timesIdea = person.timesIdea + 1
						person.lastActive = datetime.datetime.now()
						rating = Score.objects(type='submitidea')[0].value
						person.currentRating = person.currentRating + rating
						person.save()
						incrementStat('ideas',1)
						idea.save()
					except Exception as inst:
						print inst
				return HttpResponseRedirect('/')
			except:
				return HttpResponseServerError('wowza! an error occurred, sorry!')
		else:
			error_msg = u"Insufficient POST data (need 'content' and 'title'!)"
	return HttpResponseServerError(error_msg)
开发者ID:naughtond,项目名称:innuvate,代码行数:36,代码来源:views.py

示例2: submitarticle

# 需要导入模块: from models import Score [as 别名]
# 或者: from models.Score import objects [as 别名]
def submitarticle(request):
	error_msg = u"No POST data sent."	
	if request.method == "POST":
		post = request.POST.copy()
		if post.has_key('tags') and post.has_key('title') and post.has_key('url'):
			try:
				url = post['url']
				art = Article()
				art.tags = post['tags'].strip().split(',')
				art.author = str(request.user)
				art.title = post['title']
				art.votecount = 0
				art.viewcount = 0
				if not url.startswith('http://'):
					url = 'http://'+url
				art.url = url
				if art.url and art.title and art.author:
					try:
						person = getPerson(request)
						person.timesArticle = person.timesArticle + 1
						person.lastActive = datetime.datetime.now()
						rating = Score.objects(type='submitarticle')[0].value
						person.currentRating = person.currentRating + rating
						person.save()
						incrementStat('articles',1)
						art.save()
					except Exception as inst:
						print inst
				return HttpResponseRedirect('/')
			except:
				return HttpResponseServerError('wowza! an error occurred, sorry!')
		else:
			error_msg = u"Insufficient POST data (need 'content' and 'title'!)"
	return HttpResponseServerError(error_msg)
开发者ID:naughtond,项目名称:innuvate,代码行数:36,代码来源:views.py

示例3: promote

# 需要导入模块: from models import Score [as 别名]
# 或者: from models.Score import objects [as 别名]
def promote(request):
	error_msg = u"No POST data sent."	
	if request.method == "POST":
		post = request.POST.copy()
		print "promote ID: "+post['id']
		if post.has_key('id') :
			try:
				iid = post['id']
				ideas = Idea.objects(id=iid)
				print "len: "+str(len(ideas))
				if(len(ideas) >0):
					idea = ideas[0]
					idea.ispromoted = True
					incrementStat('promotions',1)
					people = Person.objects(email=idea.email)
					if people and len(people)>0:
						person = people[0]
						person.timesPromoted = person.timesPromoted +1
						rating = Score.objects(type='promotion')[0].value
						person.currentRating = person.currentRating + rating
						person.save()
					idea.save()
					try:
						t = ThreadClass("Idea Promoted", "Your idea '"+str(idea.title)+"' has been promoted and will now go forward for idea selection, it may or may not be chosen for implementation.",[idea.email])
						t.start()					
					except Exception as inst:
						print 'exception sending email '+str(inst)
						traceback.print_exc()
				return HttpResponseRedirect('/')
			except Exception as inst:
				return HttpResponseServerError('wowza! an error occurred, sorry!</br>'+str(inst))
		else:
			error_msg = u"Insufficient POST data (need 'slug' and 'title'!)"
	return HttpResponseServerError(error_msg)
开发者ID:naughtond,项目名称:innuvate,代码行数:36,代码来源:views.py

示例4: run

# 需要导入模块: from models import Score [as 别名]
# 或者: from models.Score import objects [as 别名]
	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)
开发者ID:jamesmwhite,项目名称:innuvate,代码行数:12,代码来源:idea.py

示例5: initialiseScoring

# 需要导入模块: from models import Score [as 别名]
# 或者: from models.Score import objects [as 别名]
def initialiseScoring(request):
	score = Score.objects(type='submitidea')
	if not score:
		score = Score()
		score.type='submitidea'
		score.value=100
		score.save()
	
	score = Score.objects(type='submitarticle')
	if not score:
		score = Score()
		score.type='submitarticle'
		score.value=80
		score.save()
	
	score = Score.objects(type='comment')
	if not score:
		score = Score()
		score.type='comment'
		score.value=50
		score.save()
	
	score = Score.objects(type='vote')
	if not score:
		score = Score()
		score.type='vote'
		score.value=40
		score.save()

	score = Score.objects(type='report')
	if not score:
		score = Score()
		score.type='report'
		score.value=20
		score.save()
	
	score = Score.objects(type='view')
	if not score:
		score = Score()
		score.type='view'
		score.value=10
		score.save()
	
	score = Score.objects(type='promotion')
	if not score:
		score = Score()
		score.type='promotion'
		score.value=80
		score.save()
		
	initialiseRatings()
	return HttpResponseRedirect('/')
开发者ID:naughtond,项目名称:innuvate,代码行数:54,代码来源:views.py

示例6: reportarticle

# 需要导入模块: from models import Score [as 别名]
# 或者: from models.Score import objects [as 别名]
def reportarticle(request):
	tag =  request.path_info
	tag = tag.split('/')[2]
	articles = Article.objects(id=tag)
	if len(articles)>0:
		art = articles[0]
		art.reported = True
		incrementStat('articlesreported',1)
		person = getPerson(request)
		if person:
			person.timesReport = person.timesReport +1
			rating = Score.objects(type='report')[0].value
			person.currentRating = person.currentRating + rating
			person.save()
		art.save()
	return HttpResponseRedirect('/')
开发者ID:naughtond,项目名称:innuvate,代码行数:18,代码来源:views.py

示例7: report

# 需要导入模块: from models import Score [as 别名]
# 或者: from models.Score import objects [as 别名]
def report(request):
	tag =  request.path_info
	tag = tag.split('/')[2]
	ideas = Idea.objects(id=tag)
	if len(ideas)>0:
		idea = ideas[0]
		idea.reported = True
		incrementStat('ideasreported',1)
		person = getPerson(request)
		if person:
			person.timesReport = person.timesReport +1
			rating = Score.objects(type='report')[0].value
			person.currentRating = person.currentRating + rating
			person.save()
		idea.save()
	return HttpResponseRedirect('/')
开发者ID:naughtond,项目名称:innuvate,代码行数:18,代码来源:views.py

示例8: go

# 需要导入模块: from models import Score [as 别名]
# 或者: from models.Score import objects [as 别名]
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)
开发者ID:jamesmwhite,项目名称:innuvate,代码行数:19,代码来源:managescores.py

示例9: addcomment

# 需要导入模块: from models import Score [as 别名]
# 或者: from models.Score import objects [as 别名]
def addcomment(request):
	error_msg = u"No POST data sent."
	print 'addcomment called'	
	if request.method == "POST":
		post = request.POST.copy()
		if post.has_key('content') and post.has_key('id'):
			try:
				iid = post['id']
				ideas = Idea.objects(id=iid)
				if(len(ideas) >0):
					idea = ideas[0]
					comment = Comment()
					comment.content = post['content']
					if not comment.content or comment.content.strip()=="":
						return HttpResponseRedirect('/')
					comment.author = str(request.user)
					idea.comments.append(comment)
					incrementStat('comments',1)
					person = getPerson(request)
					if person:
						person.lastActive = datetime.datetime.now()
						person.timesCommented = person.timesCommented + 1
						rating = Score.objects(type='comment')[0].value
						person.currentRating = person.currentRating + rating
						person.save()
					idea.save()
					try:
						t = ThreadClass(comment.author+" has commented on your idea: '"+idea.title+"'", comment.author+" commented: '"+comment.content+"'",[idea.email])
						t.start()					
					except Exception as inst:
						print 'exception sending email '+str(inst)
				return HttpResponseRedirect('/')
			except Exception as inst:
				return HttpResponseServerError('wowza! an error occurred, sorry!</br>'+str(inst))
		else:
			print 'didnt comment, no data'
			return HttpResponseRedirect('/')
#			error_msg = u"Insufficient POST data (need 'slug' and 'title'!)"

	return HttpResponseServerError(error_msg)
开发者ID:naughtond,项目名称:innuvate,代码行数:42,代码来源:views.py

示例10: vote

# 需要导入模块: from models import Score [as 别名]
# 或者: from models.Score import objects [as 别名]
def vote(request):
	error_msg = u"No POST data sent."	
	if request.method == "POST":
		post = request.POST.copy()
		print 'post = '+str(post)
		if post.has_key('id') and post.has_key('star1'):
			try:
				iid = post['id']
				ideas = Idea.objects(id=iid)
				if(len(ideas) >0):
					idea = ideas[0]
					curcount = idea.votecount
					print post['star1']
					voteval = int(post['star1'])		
					idea.votecount = idea.votecount + voteval
					idea.voters.append(str(request.user))
					incrementStat('unique_idea_votes',1)
					incrementStat('total_idea_vote_count',voteval)
					person = getPerson(request)
					if person:
						person.lastActive = datetime.datetime.now()
						rating = Score.objects(type='vote')[0].value
						person.currentRating = person.currentRating + rating
						person.timesVoted = person.timesVoted + 1
						person.save()
					idea.save()
					try:
						t = ThreadClass("Idea voted on", "Your idea '"+idea.title +"' has been given a voting of "+str(voteval)+".",[idea.email])
						t.start()					
					except Exception as inst:
						print 'exception sending email '+str(inst)
				return HttpResponseRedirect('/')
			except Exception as inst:
				return HttpResponseServerError('wowza! an error occurred, sorry!</br>'+str(inst))
		else:
			print 'no vote cast, no stars selected'
#			error_msg = u"Insufficient POST data (need 'slug' and 'title'!)"
			return HttpResponseRedirect('/')
	return HttpResponseServerError(error_msg)
开发者ID:naughtond,项目名称:innuvate,代码行数:41,代码来源:views.py


注:本文中的models.Score.objects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。