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))
def user_feed(request, username): the_user = get_object_or_404(User, username=username) db = get_checkins_db() user_feed = db.find(dict(username=username)).sort("timestamp", pymongo.DESCENDING) return locals()