|
@@ -202,17 +202,22 @@ def instagramUserMedia(request):
|
|
|
parsedData = getInstagram.get_user_media(access_token)
|
|
parsedData = getInstagram.get_user_media(access_token)
|
|
|
return JsonResponse({'data': parsedData })
|
|
return JsonResponse({'data': parsedData })
|
|
|
|
|
|
|
|
-def instagramMediaByLocation(request):
|
|
|
|
|
|
|
+def instagramMediaByLocation(request):
|
|
|
if request.method == 'GET':
|
|
if request.method == 'GET':
|
|
|
if request.user in User.objects.all():
|
|
if request.user in User.objects.all():
|
|
|
address = request.GET.get('address_field')
|
|
address = request.GET.get('address_field')
|
|
|
user_id = User.objects.get(username=request.user).id
|
|
user_id = User.objects.get(username=request.user).id
|
|
|
access_token = Profile.objects.get(user=user_id).oauth_secret
|
|
access_token = Profile.objects.get(user=user_id).oauth_secret
|
|
|
|
|
+ #lat, lng = getInstagram.search_for_location(address, access_token)
|
|
|
geocode_result = getInstagram.search_for_location(address, access_token)
|
|
geocode_result = getInstagram.search_for_location(address, access_token)
|
|
|
- else:
|
|
|
|
|
- geocode_result =''
|
|
|
|
|
|
|
+ if geocode_result:
|
|
|
|
|
+ location_ids =getInstagram.search_location_ids(geocode_result['lat'], geocode_result['lng'], access_token)
|
|
|
|
|
+ media = getInstagram.search_location_media(location_ids, access_token)
|
|
|
|
|
+ else:
|
|
|
|
|
+ media = ''
|
|
|
|
|
+ list_id=''
|
|
|
|
|
|
|
|
- context = {'title':'Media by location', 'geocode_result':geocode_result}
|
|
|
|
|
|
|
+ context = {'title':'Media by location', 'geocode_result':geocode_result, 'media':media, 'list_id':location_ids}
|
|
|
return render(request, 'hackathon/instagram_q.html', context)
|
|
return render(request, 'hackathon/instagram_q.html', context)
|
|
|
|
|
|
|
|
|
|
|