本文整理汇总了Python中models.Profile.accuracy方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.accuracy方法的具体用法?Python Profile.accuracy怎么用?Python Profile.accuracy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Profile
的用法示例。
在下文中一共展示了Profile.accuracy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: v1_profiles_json
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import accuracy [as 别名]
def v1_profiles_json(request):
if request.method == "POST":
action = request.POST["action"]
current_device = cache.get('%s:preferred_device' % (request.session['username'],), None)
current_presence = cache.get('%s:presence' % (request.session["username"],), 10)
if action == "remember":
if "id" in request.POST and request.POST["id"] != "":
obj = get_object_or_404(Profile, id=request.POST["id"])
else:
obj = Profile()
obj.owner = request.session["username"]
obj.name = request.POST["name"]
obj.latitude = request.POST["latitude"]
obj.longitude = request.POST["longitude"]
obj.accuracy = int(request.POST["accuracy"])
obj.presence = current_presence if request.POST["presence_id"] == "current" else request.POST["presence_id"]
obj.device = current_device if request.POST["device_id"] == "current" else request.POST["device_id"]
obj.save()
elif action == "delete":
obj = get_object_or_404(Profile, id=request.POST["id"])
obj.delete()
PRESENCE_MAP = {
1: "Do Not Disturb",
2: "Be Right Back",
3: "Unavailable",
4: "Busy",
5: "In A Meeting",
10: "Available",
}
DEVICE_MAP = {
'devices-device1': 'Home',
'devices-device2': 'Work',
'devices-device3': 'Meeting room',
'devices-device4': 'Voicemail'
}
profiles = [{
'id': p.id,
'name': p.name,
'latitude': float(p.latitude),
'longitude': float(p.longitude),
'accuracy': p.accuracy,
'presence_id': p.presence,
'presence_name': PRESENCE_MAP[int(p.presence)],
'device_id': p.device,
'device_name': DEVICE_MAP[p.device]
} for p in Profile.objects.filter(owner=request.session["username"])]
return {"success": True, "profiles": profiles}