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


Python Person.end方法代码示例

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


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

示例1: meet

# 需要导入模块: from people.models import Person [as 别名]
# 或者: from people.models.Person import end [as 别名]
def meet(request):
        # check that user is authenticated
	if (not request.user.is_authenticated()):
		return render(request, 'product_page.html')
	first = "False"
	p = Person.objects.filter(netid=request.user.username)
	if (not p):
		p1 = Person(netid=request.user.username)
		p1.save()

        # get information about the user
	currentNetid = request.user.username
	me = Person.objects.get(netid=currentNetid)

        # first time visiting the site?
	if request.method == 'GET':
		if (not isinstance(me.lat, Decimal)):
			first = "True"

        # updating profile
	if request.method == 'POST':
                # get information from the form
		pf = ProfileForm(request.POST)

                # if the form is valid, update the user's information
		if pf.is_valid():
			cd = pf.cleaned_data
			p = Person.objects.filter(netid=currentNetid)

                        # is the user already in the database? If so, just updated their info
			if (p):
				p1 = p[0];
				p1.netid = currentNetid
				p1.first_name = cd['first_name']
				p1.last_name = cd['last_name']
				p1.lat = cd['lat_s']
				p1.lon = cd['lon_s']
				p1.start = cd['start']
				p1.end = cd['end']
				p1.company = cd['company']
				p1.year = (int)(cd['year'])
				p1.desired = cd['desired']
				p1.gender = cd['gender']
				p1.save()
                        # otherwise, create a new Person for the user
			else:
				p1 = Person(netid=currentNetid, first_name=['first_name'],
				last_name=cd['last_name'], lat=cd['lat_s'],
				lon=cd['lon_s'], company=cd['company'], year=cd['year'])
				p1.save()

                        # render the templates
			t = get_template('tablefill.html')
			friends = me.friends.all()
			tfhtml = t.render(RequestContext(request, {'friend_list': friends}))
			t = get_template('myhousetablefill.html')
			myhouses = me.myhouses.all()
			myhtfhtml = t.render(RequestContext(request, {'my_houses': myhouses, 'me':me}))
			t = get_template('profile.html')
			html = t.render(RequestContext(request, {'form': pf}))
			data = {'success':'true', 'html':html, 'tfhtml':tfhtml, 'myhtfhtml':myhtfhtml}
			return HttpResponse(json.dumps(data), content_type = "application/json")

                # form is not valid
		else:
			pf.errors['lat_s'] = pf.error_class()

		t = get_template('profile.html')
		html = t.render(RequestContext(request, {'form': pf}))

		data = {'success':'false', 'html':html}
		return HttpResponse(json.dumps(data), content_type = "application/json")

	else:
		pf = ProfileForm(initial=model_to_dict(me))

	friends = me.friends.all()
	houses = me.houses.all()
	myhouses = me.myhouses.all()
	return render(request, 'meet.html', {'form': pf, 'friend_list':friends, 'house_list':houses,'my_houses':myhouses, 'firstTime':first, 'me': me})
开发者ID:dschen,项目名称:roommeet,代码行数:82,代码来源:views.py


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