當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。