|
|
@@ -36,10 +36,18 @@ 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):
|
|
|
instagram_url =getInstagram.get_authorize_url()
|
|
|
if not getTumblr.accessed:
|
|
|
@@ -49,52 +57,9 @@ def api_examples(request):
|
|
|
context = {'title': 'API Examples Page', 'tumblr_url': obtain_oauth_verifier, 'instagram_url':instagram_url}
|
|
|
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.
|
|
|
@@ -104,7 +69,32 @@ def steam(request):
|
|
|
game = gamesPulling(steamID, key)
|
|
|
return render(request,'hackathon/steam.html', {"game": game })
|
|
|
|
|
|
-def github(request):
|
|
|
+
|
|
|
+#################
|
|
|
+# GITHUB API #
|
|
|
+#################
|
|
|
+
|
|
|
+
|
|
|
+def githubUser(request):
|
|
|
+ '''Returns JSON response about a specific Github User'''
|
|
|
+
|
|
|
+ parsedData = {}
|
|
|
+ parsedData['userData'] = getUserData(settings.GITHUB_CLIENT_ID, settings.GITHUB_CLIENT_SECRET)
|
|
|
+ return JsonResponse({ 'data': parsedData })
|
|
|
+
|
|
|
+def githubTopRepositories(request):
|
|
|
+ '''Returns JSON response of a User's Top Committed repositories'''
|
|
|
+
|
|
|
+ parsedData = {}
|
|
|
+ repositories = getUserRepositories(settings.GITHUB_CLIENT_ID, settings.GITHUB_CLIENT_SECRET)
|
|
|
+ list = getTopContributedRepositories(repositories, settings.GITHUB_CLIENT_ID, settings.GITHUB_CLIENT_SECRET)
|
|
|
+ filtered = filterCommits(list)
|
|
|
+ parsedData['committed'] = filtered
|
|
|
+ return JsonResponse({ 'data': parsedData })
|
|
|
+
|
|
|
+def githubResume(request):
|
|
|
+ '''A sample application which pulls various Github data to form a Resume of sorts'''
|
|
|
+
|
|
|
allData = {}
|
|
|
userData = getUserData(settings.GITHUB_CLIENT_ID, settings.GITHUB_CLIENT_SECRET)
|
|
|
repositories = getUserRepositories(settings.GITHUB_CLIENT_ID, settings.GITHUB_CLIENT_SECRET)
|
|
|
@@ -117,9 +107,13 @@ def github(request):
|
|
|
allData['filteredData'] = filtered
|
|
|
allData['filteredStargazers'] = filteredStargazers
|
|
|
allData['forkedRepos'] = forkedRepos
|
|
|
-
|
|
|
return render(request, 'hackathon/github.html', { 'data': allData })
|
|
|
|
|
|
+
|
|
|
+#################
|
|
|
+# TUMBLR API #
|
|
|
+#################
|
|
|
+
|
|
|
def tumblr(request):
|
|
|
''' Tumblr api calls '''
|
|
|
#retrieve verifier via url link
|
|
|
@@ -139,6 +133,11 @@ def tumblr(request):
|
|
|
context = {'title': "What's up Starbucks?", 'blogData': blog, 'blogTag': tagged_blog, 'blogontag': blogontag, 'userinfo': userinfo, 'total_blog':total_blog}
|
|
|
return render(request, 'hackathon/tumblr.html', context)
|
|
|
|
|
|
+
|
|
|
+####################
|
|
|
+# INSTAGRAM API #
|
|
|
+####################
|
|
|
+
|
|
|
def instagram(request):
|
|
|
search_tag = 'kitten'
|
|
|
code = request.GET['code']
|
|
|
@@ -148,11 +147,20 @@ def instagram(request):
|
|
|
context = {'title': 'Instagram', 'tagged_media': tagged_media, 'search_tag': search_tag}
|
|
|
return render(request, 'hackathon/instagram.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.
|
|
|
@@ -172,3 +180,53 @@ 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/')
|
|
|
+
|