Beispiel #1
0
def create_path(request):
	"""Inserts a pair of lat,lng coords into Paths

	Arguments:
	request.POST.node1 -- lat,lng pair of path's first node
	request.POST.node2 -- lat,lng pair of path's seconds node

	Returns:
	Node1 and node2 coordinates (string)

	"""

	if request.method == 'POST':
		pathNode1 = request.POST.get('node1')
		pathNode2 = request.POST.get('node2')

		node1 = Nodes.objects.get(lat=pathNode1.split(',')[0], lng=pathNode1.split(',')[1])	
		node2 = Nodes.objects.get(lat=pathNode2.split(',')[0], lng=pathNode2.split(',')[1])	

		p = Paths(
			node1 = node1,
			node2 = node2
		)

		p.save()
		return HttpResponse("node1: {0} node2: {1}".format(node1, node2))
Beispiel #2
0
 def test_create_path(self):
     p = Paths(node1=self.node1, node2=self.node2)
     p.save()
     self.assertTrue(p)