Commits

Anonymous committed fb3892f

well, this is futile

  • Participants
  • Parent commits 7c395ea

Comments (0)

Files changed (4)

settings.pyc

Binary file modified.
 # Create your views here.
 #from lib.foursquare import foursquare
 import foursquare2 as foursquare
+import urllib2
+import simplejson
 from django.conf import settings
 from django.core.urlresolvers import reverse
 from django.contrib.sites.models import Site
 from team.models import *
 from django.views.generic.simple import direct_to_template
 
-access_token = 'AQQS3PSKIGU5HRX2E5I13CX3O5DLZPGB1JUTOX3TYCQGRKQX'
-fs = foursquare.FoursquareClient(access_token)
-venue = '4c5c076c7735c9b6af0e8b72'
 
 def index(request):
+    access_token = 'AQQS3PSKIGU5HRX2E5I13CX3O5DLZPGB1JUTOX3TYCQGRKQX'
+    fs = foursquare.FoursquareClient(access_token)
+    venue = '4c5c076c7735c9b6af0e8b72'
     here = fs.venues_herenow(venue)
     items = here.items()[1][1]['hereNow']['items']
     users = [i['user'] for i in items]
     return direct_to_template(request, 'index.html', {'here':repr(users)})
 
 def get_ga(request):
+    access_token = 'AQQS3PSKIGU5HRX2E5I13CX3O5DLZPGB1JUTOX3TYCQGRKQX'
+    fs = foursquare.FoursquareClient(access_token)
+    venue = '4c5c076c7735c9b6af0e8b72'
     here = fs.venues_herenow(venue)
     items = here.items()[1][1]['hereNow']['items']
     users = [i['user'] for i in items]
 
 
 def signup(request):
-    auth = foursquare.FoursquareAuthHelper("NGMJXRXNAUYGFCYRXPBWDY2SXYFOEHVI1WIAYJET0RUJOJVK", "V2VPO2OEHWFE3V1F2SECATW1V24NLK0OLYXMUES310CENMMR", 'http://outbreak.jordanorelli.com' + reverse('team-thanks'))
+    redirect_url = 'http://outbreak.jordanorelli.com' + reverse('team-thanks')
+    auth = foursquare.FoursquareAuthHelper("NGMJXRXNAUYGFCYRXPBWDY2SXYFOEHVI1WIAYJET0RUJOJVK", "V2VPO2OEHWFE3V1F2SECATW1V24NLK0OLYXMUES310CENMMR", redirect_url)
     signup_url = auth.get_authentication_url()
-    return direct_to_template(request, 'team/signup.html', { 'signup_url' : signup_url})
+    return direct_to_template(request,
+                              'team/signup.html',
+                              {'signup_url' : signup_url,
+                               'redirect_url' : redirect_url,
+                              })
 
 def thanks(request):
-    return direct_to_template(request, 'team/thanks.html')
+    if 'code' in request.GET and request.GET['code']:
+        code = request.GET['code']
+    auth = foursquare.FoursquareAuthHelper("NGMJXRXNAUYGFCYRXPBWDY2SXYFOEHVI1WIAYJET0RUJOJVK", "V2VPO2OEHWFE3V1F2SECATW1V24NLK0OLYXMUES310CENMMR", 'http://outbreak.jordanorelli.com' + reverse('team-thanks'))
+    access_token_url = auth.get_access_token_url(code)
+    f = urllib2.urlopen(access_token_url)
+    contents = f.read()
+    decoder = simplejson.decoder.JSONDecoder()
+    access_token = decoder.decode(contents)['access_token']
+
+    # client = http.client.HTTPConnection
+    # access_token = 'AQQS3PSKIGU5HRX2E5I13CX3O5DLZPGB1JUTOX3TYCQGRKQX'
+    # fs = foursquare.FoursquareClient(access_token)
+    # access_token = 'AQQS3PSKIGU5HRX2E5I13CX3O5DLZPGB1JUTOX3TYCQGRKQX'
+    fs = foursquare.FoursquareClient(access_token)
+    userdict = fs.users()
+
+    fsuer = Foursquareuser.objects.get(fid = userdict['id'])
+
+    return direct_to_template(request, 'team/thanks.html',
+                              {'code' : code,
+                               'method' : request.method,
+                               'access_token_url' : access_token_url,
+                               'access_token' : access_token,
+                               'user_dict' : repr(userdict),
+                               # 'client' : repr(fs.settings_all()),
+                              })
 
 def infect():
     #for "list of foursquare IDs":

templates/team/signup.html

 
 {% block content %}
 <a href="{{ signup_url }}">sign up.</a>
+<br />
+{{ redirect_url }}
 {% endblock %}

templates/team/thanks.html

 {% extends "base.html" %}
-{% block contet %}
+{% block content %}
 thanks.
 
+{{ method }}
+
+<br />
+
+{{ code }} 
+
+<br />
+
+<a href="{{ access_token_url }}">click here?</a>
+
+<br />
+
+{{ access_token }}
+
+<br />
+
+{{ client }}
+
+<br />
+
+{{ user_dict }}
+
 {% endblock %}