|
|
@@ -34,62 +34,28 @@ def index(request):
|
|
|
context = {'hello': 'world'}
|
|
|
return render(request, 'hackathon/index.html', context)
|
|
|
|
|
|
+##################
|
|
|
+# Twilio API #
|
|
|
+##################
|
|
|
+
|
|
|
def twilio(request):
|
|
|
sendSMS('Meow', '+13473282978', '+13473781813')
|
|
|
return render(request, 'hackathon/twilio.html')
|
|
|
|
|
|
+##################
|
|
|
+# API Examples #
|
|
|
+##################
|
|
|
+
|
|
|
def api_examples(request):
|
|
|
obtain_oauth_verifier = getTumblr.get_authorize_url()
|
|
|
#simpleoauthurl(settings.TUMBLR_CONSUMER_KEY, settings.TUMBLR_CONSUMER_SECRET)
|
|
|
context = {'title': 'API Examples Page', 'tumblr_url': obtain_oauth_verifier}
|
|
|
return render(request, 'hackathon/api_examples.html', context)
|
|
|
|
|
|
-def register(request):
|
|
|
- registered = False
|
|
|
- if request.method == 'POST':
|
|
|
- user_form = UserForm(data=request.POST)
|
|
|
- if user_form.is_valid():
|
|
|
- user = user_form.save()
|
|
|
- user.set_password(user.password)
|
|
|
- user.save()
|
|
|
- registered = True
|
|
|
- else:
|
|
|
- print user_form.errors
|
|
|
- else:
|
|
|
- user_form = UserForm()
|
|
|
-
|
|
|
-
|
|
|
- return render(request,
|
|
|
- 'hackathon/register.html',
|
|
|
- {'user_form': user_form, 'registered': registered} )
|
|
|
|
|
|
-def user_login(request):
|
|
|
-
|
|
|
-
|
|
|
- if request.method == 'POST':
|
|
|
- username = request.POST.get('username')
|
|
|
- password = request.POST.get('password')
|
|
|
-
|
|
|
-
|
|
|
- user = authenticate(username=username, password=password)
|
|
|
-
|
|
|
-
|
|
|
- if user:
|
|
|
- if user.is_active:
|
|
|
- login(request, user)
|
|
|
- return HttpResponseRedirect('/hackathon/')
|
|
|
- else:
|
|
|
- return HttpResponse("Your Django Hackathon account is disabled.")
|
|
|
- else:
|
|
|
- print "Invalid login details: {0}, {1}".format(username, password)
|
|
|
- return HttpResponse("Invalid login details supplied.")
|
|
|
-
|
|
|
- else:
|
|
|
- return render(request, 'hackathon/login.html', {})
|
|
|
-
|
|
|
-def user_logout(request):
|
|
|
- logout(request)
|
|
|
- return HttpResponseRedirect('/hackathon/')
|
|
|
+#################
|
|
|
+# STEAM API #
|
|
|
+#################
|
|
|
|
|
|
def steam(request):
|
|
|
#Should link to test of Steam API example.
|
|
|
@@ -99,6 +65,11 @@ def steam(request):
|
|
|
game = gamesPulling(steamID, key)
|
|
|
return render(request,'hackathon/steam.html', {"game": game })
|
|
|
|
|
|
+
|
|
|
+#################
|
|
|
+# GITHUB API #
|
|
|
+#################
|
|
|
+
|
|
|
def github(request):
|
|
|
allData = {}
|
|
|
userData = getUserData(settings.GITHUB_CLIENT_ID, settings.GITHUB_CLIENT_SECRET)
|
|
|
@@ -115,6 +86,11 @@ def github(request):
|
|
|
# return JsonResponse({'data': allData});
|
|
|
return render(request, 'hackathon/github.html', { 'data': allData })
|
|
|
|
|
|
+
|
|
|
+#################
|
|
|
+# TUMBLR API #
|
|
|
+#################
|
|
|
+
|
|
|
def tumblr(request):
|
|
|
''' Tumblr api calls '''
|
|
|
#retrieve verifier via url link
|
|
|
@@ -131,11 +107,21 @@ def tumblr(request):
|
|
|
context = {'title': "What's up Starbucks?", 'blogData': blog, 'blogTag': tagged_blog, 'blogontag': blogontag}
|
|
|
return render(request, 'hackathon/tumblr.html', context)
|
|
|
|
|
|
+
|
|
|
+##################
|
|
|
+# LINKED IN API #
|
|
|
+##################
|
|
|
+
|
|
|
def linkedin(request):
|
|
|
userinfo = getUserInfo()
|
|
|
context = {'title': 'linkedin Example','userdata': userinfo}
|
|
|
return render(request, 'hackathon/linkedin.html', context)
|
|
|
|
|
|
+
|
|
|
+#########################
|
|
|
+# Snippet RESTful Model #
|
|
|
+#########################
|
|
|
+
|
|
|
class JSONResponse(HttpResponse):
|
|
|
"""
|
|
|
An HttpResponse that renders its content into JSON.
|
|
|
@@ -155,3 +141,52 @@ def snippet_list(request):
|
|
|
serializer = SnippetSerializer(snippets, many=True)
|
|
|
return JSONResponse(serializer.data)
|
|
|
|
|
|
+
|
|
|
+######################
|
|
|
+# Registration Views #
|
|
|
+######################
|
|
|
+
|
|
|
+def register(request):
|
|
|
+ registered = False
|
|
|
+ if request.method == 'POST':
|
|
|
+ user_form = UserForm(data=request.POST)
|
|
|
+ if user_form.is_valid():
|
|
|
+ user = user_form.save()
|
|
|
+ user.set_password(user.password)
|
|
|
+ user.save()
|
|
|
+ registered = True
|
|
|
+ else:
|
|
|
+ print user_form.errors
|
|
|
+ else:
|
|
|
+ user_form = UserForm()
|
|
|
+
|
|
|
+
|
|
|
+ return render(request,
|
|
|
+ 'hackathon/register.html',
|
|
|
+ {'user_form': user_form, 'registered': registered} )
|
|
|
+
|
|
|
+def user_login(request):
|
|
|
+ if request.method == 'POST':
|
|
|
+ username = request.POST.get('username')
|
|
|
+ password = request.POST.get('password')
|
|
|
+
|
|
|
+
|
|
|
+ user = authenticate(username=username, password=password)
|
|
|
+
|
|
|
+
|
|
|
+ if user:
|
|
|
+ if user.is_active:
|
|
|
+ login(request, user)
|
|
|
+ return HttpResponseRedirect('/hackathon/')
|
|
|
+ else:
|
|
|
+ return HttpResponse("Your Django Hackathon account is disabled.")
|
|
|
+ else:
|
|
|
+ print "Invalid login details: {0}, {1}".format(username, password)
|
|
|
+ return HttpResponse("Invalid login details supplied.")
|
|
|
+
|
|
|
+ else:
|
|
|
+ return render(request, 'hackathon/login.html', {})
|
|
|
+
|
|
|
+def user_logout(request):
|
|
|
+ logout(request)
|
|
|
+ return HttpResponseRedirect('/hackathon/')
|