def MainHub(request): loggedin, data = ttagServiceAuth(request) #"owner_id":"5064dd00559ae9da2b9e38b8","location_type":"HUB","user_id":"5064dd00559ae9da2b9e38b8","access_token":"ff891baeb4106593b40a5b9110c90f44" if loggedin: user_id = data["_id"] user_name = data["user_name"] response_hubs = ttagGetHubsByUserName(data['user_name']) #print response_hubs response_count = ttagRequestCount(data['_id']) counts = response_count['counts'] block_title = "My Hubs" if response_hubs["result"] == "OK": hubs = response_hubs["data"]["hubs"] logined_and_different = False joined_hubs = ttagGetJoinedHubsByUserName(user_name)["data"]["hubs"] for hub in response_hubs["data"]["hubs"]: if hub["creater_id"] == user_id: hub["owner"] = True else: hub["owner"] = False hububub = ttagGetHubByHubId(hub["hub_id"]) #print hububub hub["joined"] = False for joined_hub in joined_hubs: #print "Joined Hub:" + hub["hub_name"]+":" + joined_hub["_id"] + "======" + hub["_id"]+":"+hub["hub_name"] if joined_hub["_id"] == hub["_id"]: hub["joined"] = True break return render_to_response('hub/user_hubs.html', locals(), context_instance=RequestContext(request)) else: return HttpResponse(response_hubs["msg"]) else: return HttpResponseRedirect('/')
def get_hubs_by_user(request, user): if not user.user_name in hub_registry.hub_lists_by_user: response_hubs = ttagGetHubsByUserName(user.user_name) if("data" in response_hubs and "hubs" in response_hubs["data"]): hubs = processRawHubs(response_hubs['data']['hubs'], request) hub_registry.hub_lists_by_user[user.user_name] = processHubList(hubs, user) else: hub_registry.hub_lists_by_user[user.user_name] = [] return hub_registry.hub_lists_by_user[user.user_name]
def getHubOwners(request, data_type,data_value): if data_type == "name": response = ttagGetHubsByUserName(data_value) elif data_type == "id": response = ttagGetHubsByOwnerId(data_value) else: return HttpResponse("Invalid data type") if response["result"] == "OK": context = {'hubs': response["data"]["hubs"]} thereturn = render_to_response('hub/user_hubs.html', context, context_instance=RequestContext(request)) return thereturn else: return HttpResponse(response["msg"])
def getHubDetails(request, data_type,data_value, partial="false"): aToken = request.COOKIES['access_token'] if data_type == "name": response = ttagGetHubsByUserName(data_value) elif data_type == "id": response = ttagGetHubsByOwnerId(data_value, aToken) else: return HttpResponse("Invalid data type") if response["result"] == "OK": context = {'hubs': response["data"]["hubs"],'request':request} thereturn = render_to_response('hub/user_hubs.html', context, context_instance=RequestContext(request)) return thereturn else: return HttpResponse(response["msg"])
def getHubOwners(request, data_type, data_value): if data_type == "name": response = ttagGetHubsByUserName(data_value) elif data_type == "id": response = ttagGetHubsByOwnerId(data_value) else: return HttpResponse("Invalid data type") if response["result"] == "OK": context = {'hubs': response["data"]["hubs"]} thereturn = render_to_response( 'hub/user_hubs.html', context, context_instance=RequestContext(request)) return thereturn else: return HttpResponse(response["msg"])
def getHubDetails(request, data_type, data_value, partial="false"): aToken = request.COOKIES['access_token'] if data_type == "name": response = ttagGetHubsByUserName(data_value) elif data_type == "id": response = ttagGetHubsByOwnerId(data_value, aToken) else: return HttpResponse("Invalid data type") if response["result"] == "OK": context = {'hubs': response["data"]["hubs"], 'request': request} thereturn = render_to_response( 'hub/user_hubs.html', context, context_instance=RequestContext(request)) return thereturn else: return HttpResponse(response["msg"])
def MainHub(request): loggedin, data = ttagServiceAuth(request) #"owner_id":"5064dd00559ae9da2b9e38b8","location_type":"HUB","user_id":"5064dd00559ae9da2b9e38b8","access_token":"ff891baeb4106593b40a5b9110c90f44" if loggedin: user_id = data["_id"] user_name = data["user_name"] response_hubs = ttagGetHubsByUserName(data['user_name']) #print response_hubs response_count = ttagRequestCount(data['_id']) counts = response_count['counts'] block_title = "My Hubs" if response_hubs["result"] == "OK": hubs = response_hubs["data"]["hubs"] logined_and_different = False joined_hubs = ttagGetJoinedHubsByUserName( user_name)["data"]["hubs"] for hub in response_hubs["data"]["hubs"]: if hub["creater_id"] == user_id: hub["owner"] = True else: hub["owner"] = False hububub = ttagGetHubByHubId(hub["hub_id"]) #print hububub hub["joined"] = False for joined_hub in joined_hubs: #print "Joined Hub:" + hub["hub_name"]+":" + joined_hub["_id"] + "======" + hub["_id"]+":"+hub["hub_name"] if joined_hub["_id"] == hub["_id"]: hub["joined"] = True break return render_to_response('hub/user_hubs.html', locals(), context_instance=RequestContext(request)) else: return HttpResponse(response_hubs["msg"]) else: return HttpResponseRedirect('/')
def getUserHubs(request,data_type,data_value,hub_type): authed, data = ttagServiceAuth(request) joined_hubs = [] block_title = "" if authed: response_count = ttagRequestCount(data['_id']) counts = response_count['counts'] access_token = request.COOKIES['access_token'] user_id = data["_id"] user_name = data["user_name"] if data_type == "name": if hub_type == "created": block_title = "My Hubs" response = ttagGetHubsByUserName(data_value, request.COOKIES['access_token']) elif hub_type == "member": block_title = "Joined Hubs" response = ttagGetJoinedHubsByUserName(data_value) else: response = ttagGetHubsByUserName(data_value) elif data_type == "id": if hub_type == "created": block_title = "My Hubs" response = ttagGetHubsByOwnerId(data_value, request.COOKIES['access_token']) elif hub_type == "member": block_title = "Joined Hubs" response = ttagGetJoinedHubsByHubUserId(data_value) else: response = ttagGetHubsByOwnerId(data_value) elif request.method == 'POST': if request.POST['find_method'] == 'id': response = ttagGetHubsByOwnerId(request.POST['query'], access_token) elif request.POST['find_method'] == 'name': response = ttagGetHubsByUserName(request.POST['query']) if response["result"] == "OK": logined_and_different = (data_value != user_name and len(user_name) > 0) if logined_and_different: joined_hubs = ttagGetJoinedHubsByUserName(user_name)["data"]["hubs"] for hub in response["data"]["hubs"]: if hub["creater_id"] == user_id: hub["owner"] = True else: hub["owner"] = False hub["joined"] = False for joined_hub in joined_hubs: #print "Joined Hub:" + hub["hub_name"]+":" + joined_hub["_id"] + "======" + hub["_id"]+":"+hub["hub_name"] if joined_hub["_id"] == hub["_id"]: hub["joined"] = True break hubs = response['data']['hubs'] #print 'user_id:' + user_id #context = {'hubs': response["data"]["hubs"],"user_id":user_id,"joined_hubs":joined_hubs,"logined_and_different":logined_and_different} thereturn = render_to_response('hub/user_hubs_joined.html', locals(), context_instance=RequestContext(request)) return thereturn else: return HttpResponse(response["msg"]) else: return HttpResponseRedirect('/') return thereturn
def getUserHubs(request, data_type, data_value, hub_type): authed, data = ttagServiceAuth(request) joined_hubs = [] block_title = "" if authed: response_count = ttagRequestCount(data['_id']) counts = response_count['counts'] access_token = request.COOKIES['access_token'] user_id = data["_id"] user_name = data["user_name"] if data_type == "name": if hub_type == "created": block_title = "My Hubs" response = ttagGetHubsByUserName( data_value, request.COOKIES['access_token']) elif hub_type == "member": block_title = "Joined Hubs" response = ttagGetJoinedHubsByUserName(data_value) else: response = ttagGetHubsByUserName(data_value) elif data_type == "id": if hub_type == "created": block_title = "My Hubs" response = ttagGetHubsByOwnerId( data_value, request.COOKIES['access_token']) elif hub_type == "member": block_title = "Joined Hubs" response = ttagGetJoinedHubsByHubUserId(data_value) else: response = ttagGetHubsByOwnerId(data_value) elif request.method == 'POST': if request.POST['find_method'] == 'id': response = ttagGetHubsByOwnerId(request.POST['query'], access_token) elif request.POST['find_method'] == 'name': response = ttagGetHubsByUserName(request.POST['query']) if response["result"] == "OK": logined_and_different = (data_value != user_name and len(user_name) > 0) if logined_and_different: joined_hubs = ttagGetJoinedHubsByUserName( user_name)["data"]["hubs"] for hub in response["data"]["hubs"]: if hub["creater_id"] == user_id: hub["owner"] = True else: hub["owner"] = False hub["joined"] = False for joined_hub in joined_hubs: #print "Joined Hub:" + hub["hub_name"]+":" + joined_hub["_id"] + "======" + hub["_id"]+":"+hub["hub_name"] if joined_hub["_id"] == hub["_id"]: hub["joined"] = True break hubs = response['data']['hubs'] #print 'user_id:' + user_id #context = {'hubs': response["data"]["hubs"],"user_id":user_id,"joined_hubs":joined_hubs,"logined_and_different":logined_and_different} thereturn = render_to_response( 'hub/user_hubs_joined.html', locals(), context_instance=RequestContext(request)) return thereturn else: return HttpResponse(response["msg"]) else: return HttpResponseRedirect('/') return thereturn