Ejemplo n.º 1
0
def getUserHubs(user_name):
    hubs = []
    respHubs = ttagGetJoinedHubsByUserName(user_name)
    #print respHubs
    if 'data' in respHubs and 'hubs' in respHubs['data'] and respHubs['data']['hubs'] != None :
        hubs = [hub['_id'] for hub in respHubs['data']['hubs']]
    return hubs;
Ejemplo n.º 2
0
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('/')
Ejemplo n.º 3
0
def getUserHubs(user_name):
    hubs = []
    respHubs = ttagGetJoinedHubsByUserName(user_name)
    #print respHubs
    if 'data' in respHubs and 'hubs' in respHubs[
            'data'] and respHubs['data']['hubs'] != None:
        hubs = [hub['_id'] for hub in respHubs['data']['hubs']]
    return hubs
Ejemplo n.º 4
0
def findHubsGeneral(request):

    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 request.method == 'POST' and request.POST[
                'find_method'] == 'general':
            response = ttagGetHubsByName(request.POST['query'])
            if response["result"] == 'OK':
                hubs = response['data']['hubs']

                logined_and_different = False
                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

                thereturn = render_to_response(
                    'hub/find_hubs_general.html',
                    locals(),
                    context_instance=RequestContext(request))
            else:
                return HttpResponse(response["msg"])
        else:
            #context = {'hubs': response["data"]["hubs"],"user_id":user_id,"joined_hubs":joined_hubs,"logined_and_different":logined_and_different}
            thereturn = render_to_response(
                'hub/find_hubs_general.html',
                locals(),
                context_instance=RequestContext(request))
        return thereturn
    else:
        return HttpResponseRedirect('/')
Ejemplo n.º 5
0
def JoinedHub(request, data_type, data_value):
    loggedin, data = ttagServiceAuth(request)
    response_count = ttagRequestCount(data['_id'])
    counts = response_count['counts']
    
    if loggedin:
        if data_type == 'id':
            response_joined = ttagGetJoinedHubsByHubUserId(data_value)
        elif data_type == 'name':
            response_joined = ttagGetJoinedHubsByUserName(data_value)
            
        if response_joined["result"] == "OK":
            hubs = response_joined["data"]["hubs"]
            return render_to_response('hub/user_hubs.html', locals(), context_instance=RequestContext(request))
        else:
            return HttpResponse(response_joined.msg)
    else:
        return HttpResponseRedirect('/')
Ejemplo n.º 6
0
def findHubsGeneral(request):

    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 request.method == 'POST' and request.POST['find_method'] == 'general':
            response = ttagGetHubsByName(request.POST['query'])
            if response["result"] == 'OK':
                hubs = response['data']['hubs']
                
                logined_and_different = False
                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
                
                thereturn = render_to_response('hub/find_hubs_general.html', locals(), context_instance=RequestContext(request))
            else:
                return  HttpResponse(response["msg"])
        else:
            #context = {'hubs': response["data"]["hubs"],"user_id":user_id,"joined_hubs":joined_hubs,"logined_and_different":logined_and_different}
            thereturn = render_to_response('hub/find_hubs_general.html', locals(), context_instance=RequestContext(request))
        return thereturn                
    else:
        return HttpResponseRedirect('/')
Ejemplo n.º 7
0
def JoinedHub(request, data_type, data_value):
    loggedin, data = ttagServiceAuth(request)
    response_count = ttagRequestCount(data['_id'])
    counts = response_count['counts']

    if loggedin:
        if data_type == 'id':
            response_joined = ttagGetJoinedHubsByHubUserId(data_value)
        elif data_type == 'name':
            response_joined = ttagGetJoinedHubsByUserName(data_value)

        if response_joined["result"] == "OK":
            hubs = response_joined["data"]["hubs"]
            return render_to_response('hub/user_hubs.html',
                                      locals(),
                                      context_instance=RequestContext(request))
        else:
            return HttpResponse(response_joined.msg)
    else:
        return HttpResponseRedirect('/')
Ejemplo n.º 8
0
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('/')
Ejemplo n.º 9
0
 def get_joined_hub_ids(self):
     if self.joined_hub_ids == []:
         hubs = ttagGetJoinedHubsByUserName(self.user_name)["data"]["hubs"]
         self.joined_hub_ids = [hub["_id"] for hub in hubs]
     return self.joined_hub_ids
Ejemplo n.º 10
0
	def get_joined_hub_ids(self):
		if self.joined_hub_ids == []:
			hubs = ttagGetJoinedHubsByUserName(self.user_name)["data"]["hubs"]
			self.joined_hub_ids = [hub["_id"] for hub in hubs]
		return self.joined_hub_ids
Ejemplo n.º 11
0
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   
Ejemplo n.º 12
0
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