本文整理汇总了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} )
示例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} )
示例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: