Beispiel #1
0
def index(request):
    """
    The URL handler for the Post request from txtlocal
    http://www.txtlocal.co.uk/
    Parses for a location message and adds a Waypoint 
    """
    if request.method == 'POST':
        lat, long = get_coords(request.raw_post_data)
        if lat is not None and long is not None:
            timestamp = datetime.utcnow().isoformat()
            wp = Waypoint(name = timestamp, 
                          geometry = 'POINT(%s %s)'%(long, lat))
            wp.save()
    return HttpResponse("")
Beispiel #2
0
 def test_get_coords(self):
     expected = (51.471449999999997, -2.5865999999999998)
     self.assertEquals(expected, get_coords(raw_data))