Esempio n. 1
0
def homepage(request, country_slug=None, city_slug=None):
    locate_me = "locate-me" in request.GET
    location = get_location(request)
    city = get_city(request, country_slug, city_slug)
    center = [city.location[1], city.location[0]]
    checkins = list(get_checkins(center))
    checkins_json = json.dumps(checkins, cls=MongoJSONEncoder)
    continents = CONTINENTS
    return locals()
Esempio n. 2
0
def checkins(request, checkin_id=None):
    now = timezone.now().replace(hour=0, minute=1)
    db = get_checkins_db()

    if request.method == "GET" and checkin_id:
        data = db.find_one({"_id": checkin_id})
        if not data:
            raise Http404

    elif request.method == "GET" and not checkin_id:
        data = get_checkins(get_location(request))

    elif request.method == "POST" and not checkin_id:
        post_data = json.loads(request.POST.keys()[0])
        form = LocationForm(data=post_data["location"])
        if form.is_valid():
            data = form.save(request, geocode=post_data["geocode"][0])

    return HttpResponse(json.dumps(data, cls=MongoJSONEncoder))