Permalink
Browse files

added sample data for frontend

  • Loading branch information...
1 parent 9367354 commit 4f17878ee66949d0b428be5d7521ee4cc729d7ca @systemizer committed Jun 24, 2012
Showing with 41 additions and 1 deletion.
  1. +13 −0 batteries/bapi/utils.py
  2. +25 −1 batteries/bapi/views.py
  3. +3 −0 manage.py
@@ -0,0 +1,13 @@
+import urllib
+
+MEETUP_URL_ROOT = "https://api.meetup.com/2/open_events.json"
+
+def generate_meetup_url(lat,lon,cur_time):
+ interval = [cur_time-1000*60*30,cur_time+1000*60*60*1.5] #interval of time is 30 minutes prior and 1.5 hours later
+ payload = {'lat':lat,'lon':lon,time:"%s,%s" % (interval[0],interval[1])}
+ return "%s?%s" % (MEETUP_URL_ROOT,urllib.urlencode(payload))
+
+
+provider_url_generators = {
+ 'meetup':generate_meetup_url,
+}
@@ -1,11 +1,35 @@
from django.shortcuts import render_to_response
from django.template import RequestContext
+from django.http import HttpResponse
+
+from batteries.bapi.utils import provider_url_generators
+
import grequests
+import urllib
+import time
+import json
+
def home(request):
return render_to_response("home.html",{},RequestContext(request))
def events(request):
lat = request.GET.get("lat")
lon = request.GET.get("lon")
- timestamp = request.GET.get("t")
+
+ cur_time = int(time.time()*1000)
+
+ #urls = [url_gen(lat,lon,cur_time) for url_gen in provider_url_generators.values()]
+
+ payload = {'query':'select eid,start_time,end_time,location,name,description,pic_square from event where eid=209798352393506','format':'json'}
+ url = "https://api.facebook.com/method/fql.query?%s" % (urllib.urlencode(payload))
+
+ urls = [url]
+
+ rs = (grequests.get(u) for u in urls)
+ results = grequests.map(rs)
+ result = json.loads(results[0].text)
+ result_json = {'results':[result[0],result[0],result[0],result[0]]}
+ return HttpResponse(json.dumps(result_json))
+
+
View
@@ -4,6 +4,9 @@
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "batteries.settings")
+ import gevent
+ from gevent import monkey
+ monkey.patch_all()
from django.core.management import execute_from_command_line

0 comments on commit 4f17878

Please sign in to comment.