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


Python Box.objects方法代码示例

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


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

示例1: savePaths

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import objects [as 别名]
def savePaths(request, paths, strokeWidth, strokeColor, object_type, fillColor=None):
	# if not request.user.is_authenticated():
	# 	return simplejson.dumps({'state': 'not_logged_in'})
	
	print "hih"
	print request.user.username

	pIDs = []
	pks = []

	for path in paths:
		pID = path['pID']
		points = path['points']
		planet = str(path['planet']['x'])+','+str(path['planet']['y'])

		lockedAreas = Box.objects(planet=planet, box__geo_intersects={"type": "LineString", "coordinates": points } )
		if lockedAreas.count()>0:
			return simplejson.dumps( {'state': 'error', 'message': 'Your drawing intersects with a locked area'} )

		p = Path(planet=planet, points=points, owner=request.user.username, strokeColor=strokeColor, fillColor=fillColor, strokeWidth=strokeWidth, object_type=object_type, pID=pID )
		p.save()

		pIDs.append(pID)
		pks.append(p.pk)

	return simplejson.dumps( {'state': 'success', 'pIDs': pIDs, 'pk': pks} )
开发者ID:arthur-test-account,项目名称:Romanesco,代码行数:28,代码来源:ajax.py

示例2: load

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import objects [as 别名]
def load(request, areasToLoad):

	paths = []
	boxes = []

	for area in areasToLoad:
				
		tlX = area['pos']['x']
		tlY = area['pos']['y']

		planet = str(area['planet']['x'])+','+str(area['planet']['y'])

		p = Path.objects(planet=planet, points__geo_intersects=makeBox(tlX, tlY, tlX+1, tlY+1) )
		b = Box.objects(planet=planet, box__geo_intersects=makeBox(tlX, tlY, tlX+1, tlY+1) )

		paths.append(p.to_json())
		boxes.append(b.to_json())

	return simplejson.dumps( {'paths': paths, 'boxes': boxes, 'user': request.user.username} )
开发者ID:arthur-test-account,项目名称:Romanesco,代码行数:21,代码来源:ajax.py

示例3: saveBoxes

# 需要导入模块: from models import Box [as 别名]
# 或者: from models.Box import objects [as 别名]
def saveBoxes(request, boxes, bb, object_type, message, name="", url="", modify=None, pk=None):
	if not request.user.is_authenticated():
		return simplejson.dumps({'state': 'not_logged_in'})

	validate = URLValidator()
	if object_type=='link' and url != "":
		try:
			validate(url)
		except ValidationError, e:
			print e
			return simplejson.dumps({'state': 'error', 'message': 'invalid_url'})
	elif object_type=='link' and url == "":
		return simplejson.dumps({'state': 'system_error', 'message': 'invalid_data'})

	if modify:
		boxes = Box.objects(pk=pk, owner=request.user.username)
		if not boxes:
			return simplejson.dumps({'state': 'error', 'message': 'Element does not exist for this user'})
		for box in boxes:
			box.name = name
			box.url = url
			box.message = message
			box.save()
			return simplejson.dumps( {'state': 'success', 'bb': bb, 'object_type':object_type, 'message': message, 'name': name, 'url': url, 'owner': request.user.username, 'pk':str(box.pk), 'box':box.box, 'planet': box.planet,  'modified': True } )

	for box in boxes:
		
		points = box['points']
		planet = str(box['planet']['x'])+','+str(box['planet']['y'])
		lockedAreas = Box.objects(planet=planet, box__geo_intersects=makeBox(points[0][0], points[0][1], points[2][0], points[2][1]) )
		if lockedAreas.count()>0:
开发者ID:arthur-test-account,项目名称:Romanesco,代码行数:33,代码来源:ajax.py


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