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


Python Report.device方法代码示例

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


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

示例1: cpanel_submit

# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import device [as 别名]
def cpanel_submit(request):
	# The user adding the request
	user = request.user

	name = request.POST['name']
	phone = request.POST['phone']
	email = request.POST['email']
	type = request.POST['device']
	os = request.POST['os']
	problem = request.POST['problem']
	description = request.POST['description']
	deviceObj = Device()
	report = Report()
	usersWithSameEmail = User.objects.filter(email=email)
	reportUser = User()

	userFound = False
	for u in usersWithSameEmail:
		# If user exists, don't create a new one
		if u.email == email:
			reportUser = u
			userFound = True

	if not userFound:
		reportUser.email = email
		reportUser.username = name
		reportUser.password = 'password'
		reportUser.save()

	# Get the devices the user has
	usersDevices = Device.objects.filter(owner=reportUser)

	deviceFound = False
	for d in usersDevices:
		# If the device exists recognize it, and use it
		if d.os == os and d.type == type:
			deviceObj = d
			deviceFound = True

	if not deviceFound:
		# Generate device object
		deviceObj.owner = reportUser
		deviceObj.os = os
		deviceObj.type = type
		deviceObj.save()

	# Generate Report
	report.owner = reportUser
	report.device = deviceObj
	report.description = description
	report.problem = problem
	report.completed = False
	report.save()

	# Generate initial status
	status = Status()
	status.report = report
	# Checked in message
	status.message = 'c'
	status.tech = user
	status.save()

	return cpanel(request, True)
开发者ID:BobNisco,项目名称:fall-2012-hackathon,代码行数:65,代码来源:views.py


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