Ejemplo n.º 1
0
def add_point(request):
	point = Point()
	point.save(request.user, 
					request.POST.get("latitude", None),
					request.POST.get("longitude", None),
					request.POST.get("description", ""),
					request.POST.get("title", None))

	properties = json.loads(request.POST["properties"])
	for prop in properties:
		obj = Point_and_Property()
		obj.save(point, Property.objects.get(id = prop["id"]), prop["value"])

	return point.id
Ejemplo n.º 2
0
def update_point(request):
	id = request.POST.get("id", None)
	point = Point.objects.get(id=id)
	if not point:
		raise Exception("Wrong id")

	point.save(request.user, 
					request.POST.get("latitude", None),
					request.POST.get("longitude", None),
					request.POST.get("description", ""),
					request.POST.get("title", None))

	properties = json.loads(request.POST["properties"])
	print point.id
	# print prop["id"]
	for prop in properties:
		try:
			obj = Point_and_Property.objects.get(point=point.id, prop=prop["id"])
		except ObjectDoesNotExist:
			obj = Point_and_Property()
		obj.save(point, Property.objects.get(id=prop["id"]), prop["value"])

	return point.id