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


Python Person.objects方法代码示例

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


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

示例1: get_epithet

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import objects [as 别名]
def get_epithet(name):

    person = Person.objects(name=name).first()

    if person:
        return person.epithet
    else:
        epithets = Epithet.objects().all().values_list('epithet')
        num_of_epithets = Person.objects().count()

        choosen_epithet = epithets[random.randint(0, num_of_epithets)]

        Person(name=name, epithet=choosen_epithet).save()

        return choosen_epithet
开发者ID:julishpak,项目名称:EVO_task2,代码行数:17,代码来源:utils.py

示例2: promote

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person 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

示例3: inventory_update_view

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import objects [as 别名]
def inventory_update_view():
    if login.current_user.is_anonymous():
        abort()
    # 1 = checkin, 2 = checkout
    status = int(request.form["status"])
    checkout_meta = None
    # provide meta
    if status == InventoryItem.CHECKED_OUT:  # checkout
        dtype = int(request.form["duration_type"])
        duration = request.form["duration"]
        try:
            duration = int(duration)
            # enforce duration limit
            if duration > 999:
                duration = 999
        except ValueError:
            duration = 0
        checkout_meta = CheckoutMeta(
            duration=duration, duration_type=dtype, is_ooo=(True if int(request.form.get("ooo", 0)) else False)
        )
    person = Person.objects(id=request.form["personid"]).get()
    item = InventoryItem.objects(id=request.form["itemid"]).get()
    # add a log
    log = InventoryLog.add_log(
        person=person, item=item, status=int(request.form["status"]), checkout_meta=checkout_meta
    )
    # update the item status
    item.status = status
    item.save()
    response = {
        "duration": {"dateAdded": log.get_date_added(), "description": log.get_checkout_description()},
        "person": {"name": log.person.name},
    }
    return json.dumps(response)
开发者ID:cbess,项目名称:inventory-checkin,代码行数:36,代码来源:views.py

示例4: go

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

示例5: getPerson

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import objects [as 别名]
def getPerson(request):
	people = Person.objects(email=str(request.user.email))
	if people and len(people)>0:
		person = people[0]
		return person
	return None
开发者ID:naughtond,项目名称:innuvate,代码行数:8,代码来源:views.py


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