def ViewFriendTrack(request, authid):
    context = RequestContext(request)
    cursor = connection.cursor()
    cursor.execute("SELECT * from pahera_viewfriendtracks WHERE auth_id = %s", [authid])
    track_details = DictFetchAll.dictfetchall(cursor)
    js_data = {}
    trackData = {}
    single_track = []
    for data in track_details:
        trackData["person_id"] = data["person_id"]
        cursor1 = connection.cursor()
        cursor1.execute("SELECT * from pahera_person WHERE id = %s", [data["person_id"]])
        person_Data = DictFetchAll.dictfetchall(cursor1)
        trackData["first_name"] = person_Data[0]["first_name"]
        trackData["last_name"] = person_Data[0]["last_name"]
        trackData["location_lat"] = str(data["latitude"])
        trackData["location_long"] = str(data["longitude"])
        lati = data["latitude"]
        longi = data["longitude"]
        trackData["location_name"] = data["address"]
        trackData["time"] = str(data["time"])
        trackData["date"] = str(data["date"])
        trackData["id"] = data["id"]
        trackData["message"] = data["message"]
        single_track.append(dict(trackData))
        js_data["res"] = single_track
    scriptpath = os.path.dirname("./static/JSON/temp")
    fName = os.path.join(scriptpath, "FriendTrack.json")
    WritingToJson.writeJSON(js_data, fName)

    return render_to_response("pahera/viewFriendTracks.html", context)
def Home(request):
    context = RequestContext(request)
    track_details = {}
    person_ID = request.session.get("username", None)
    cursor = connection.cursor()
    cursor1 = connection.cursor()
    person_Data2 = {}
    person_Data2["person"] = Person.objects.get(id=person_ID)
    cursor1.execute("SELECT * from pahera_person WHERE id = %s", [person_ID])
    person_Data = DictFetchAll.dictfetchall(cursor1)
    cursor.execute("SELECT * from pahera_tracks")
    track_details = DictFetchAll.dictfetchall(cursor)
    js_data = {}
    trackData = {}
    single_track = []
    for data in track_details:
        if data["person_id"] == person_ID:
            trackData["person_id"] = data["person_id"]
            trackData["first_name"] = person_Data[0]["first_name"]
            trackData["last_name"] = person_Data[0]["last_name"]
            trackData["location_lat"] = str(data["latitude"])
            trackData["location_long"] = str(data["longitude"])
            lati = data["latitude"]
            longi = data["longitude"]
            trackData["location_name"] = data["address"]
            trackData["time"] = str(data["time"])
            trackData["date"] = str(data["date"])
            trackData["id"] = data["id"]
            trackData["message"] = data["message"]
            single_track.append(dict(trackData))
        js_data["res"] = single_track
    scriptpath = os.path.dirname("./static/JSON/temp/")
    fName = os.path.join(scriptpath, "TrackResults.json")
    WritingToJson.writeJSON(js_data, fName)
    return render_to_response("pahera/home.html", person_Data2, context)