Exemplo n.º 1
0
def search(request, user_name=''):
    try:
        thereturn = loginscreen(request)
        loggedin, user, loggedin_user, follow, data = getUserVariables(
            request, user_name)
        if loggedin:
            user_name = user['user_name']
            if not request.POST:
                thereturn = render_to_response(
                    'partial_user_searchhub.html',
                    locals(),
                    context_instance=RequestContext(request))
            elif 'query' in request.POST and len(request.POST['query']) > 0:
                response = ttagGetHubsByName(request.POST['query'])
                if response['result'] == 'OK':
                    response['data']['hubs'] = processRawHubs(
                        response['data']['hubs'], request)
                    from webapp.views.user import getUserHubs
                    response['data']['joinedhubs'] = getUserHubs(
                        user['user_name'])
                    thereturn = render_to_response(
                        'partial_userhub_searchresults.html',
                        locals(),
                        context_instance=RequestContext(request))
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
Exemplo n.º 2
0
def search(request, user_name=''):
    try :
        thereturn = loginscreen(request)
        loggedin, user, loggedin_user, follow, data = getUserVariables(request, user_name)
        if loggedin :
            user_name = user['user_name']
            if not request.POST :
                thereturn = render_to_response('partial_user_searchhub.html',locals(),context_instance=RequestContext(request))
            elif 'query' in request.POST and len(request.POST['query']) > 0 :
                response = ttagGetHubsByName(request.POST['query'])
                if response['result'] == 'OK' :
                    response['data']['hubs'] = processRawHubs(response['data']['hubs'], request)
                    from webapp.views.user import getUserHubs
                    response['data']['joinedhubs'] = getUserHubs(user['user_name'])
                    thereturn = render_to_response('partial_userhub_searchresults.html',locals(),context_instance=RequestContext(request))
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
Exemplo n.º 3
0
def listJoined(request, user_name):
    try:
        thereturn = custompopup(
            request, '<p>Sorry, we were unable to display this page.</p>')
        loggedin, user, loggedin_user, follow, data = getUserVariables(
            request, user_name)
        logged_in_user = get_logged_in_user(request)
        request_user = get_user_by_name(request, user_name)
        if request_user != False:
            respHubs = ttagGetJoinedHubsByHubUserId(data['_id'])
            hubs = processRawHubs(respHubs['data']['hubs'], request)
            if len(hubs) == 0:
                if loggedin and user_name == user['user_name']:
                    thereturn = render_to_response(
                        'partial_user_nohubsmyself.html',
                        locals(),
                        context_instance=RequestContext(request))
                else:
                    thereturn = render_to_response(
                        'partial_user_nohubs.html',
                        locals(),
                        context_instance=RequestContext(request))
            else:
                response = {'data': {'hubs': hubs}}
                if loggedin:
                    from webapp.views.user import getUserHubs
                    response['data']['joinedhubs'] = getUserHubs(
                        user['user_name'])
                thereturn = render_to_response(
                    'partial_user_hubs.html',
                    locals(),
                    context_instance=RequestContext(request))
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
Exemplo n.º 4
0
def listJoined(request, user_name):
    try :
        thereturn = custompopup(request,'<p>Sorry, we were unable to display this page.</p>')
        loggedin, user, loggedin_user, follow, data = getUserVariables(request, user_name)
        logged_in_user = get_logged_in_user(request)
        request_user = get_user_by_name(request, user_name)
        if request_user != False :
            respHubs = ttagGetJoinedHubsByHubUserId(data['_id'])
            hubs = processRawHubs(respHubs['data']['hubs'], request)
            if len(hubs) == 0 :
                if loggedin and user_name == user['user_name'] :
                    thereturn = render_to_response('partial_user_nohubsmyself.html',locals(),context_instance=RequestContext(request))
                else :
                    thereturn = render_to_response('partial_user_nohubs.html',locals(),context_instance=RequestContext(request))
            else :
                response = {'data': {'hubs': hubs }}
                if loggedin :
                    from webapp.views.user import getUserHubs
                    response['data']['joinedhubs'] = getUserHubs(user['user_name'])
                thereturn = render_to_response('partial_user_hubs.html',locals(),context_instance=RequestContext(request))
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
Exemplo n.º 5
0
def search(request):
    try:
        thereturn = loginscreen(request)
        loggedin, data = ttagServiceAuth(request)
        if loggedin:
            if 'search' in request.POST:
                atusername = ''
                emailform = SpraycanSearchEmail(request.POST)
                usernameform = SpraycanSearchUsername(request.POST)
                if emailform.is_valid():
                    resp = ttagPost('/validate/request-username-by-email',
                                    {'email': emailform.getSpraycan_Search()})
                    if resp['result'] == 'OK' and resp['find_by_email']:
                        atusername = resp['user_name']
                elif usernameform.is_valid():
                    resp = ttagRequestUserProfile(
                        usernameform.getSpraycan_Search()[1:])
                    if resp['result'] == 'OK':
                        atusername = resp['data']['user_name']
                if atusername != '':
                    #                from django.core.urlresolvers import reverse
                    #                return render_to_response("javascript_redirect.html", {"redirect_url" : reverse('user-profile', kwargs={'user_name':atusername,'view_type':'','page':'','time':''}),'hidespraycan':'true'})
                    from webapp.views.user import userWallView
                    return userWallView(request, atusername)
                form = SpraycanSearch(request.POST)
                if form.is_valid():
                    urlform = SpraycanSearchURL(request.POST)
                    if urlform.is_valid():
                        #show spraycan for URL
                        thereturn = url(request, urlform.getSpraycan_Search())
                    else:
                        #show search results
                        import datetime
                        from webapp.views.user import getUserFollowers
                        location_type = 'search'
                        loggedin_user = data['_id']
                        filter = request.POST.get('filter', "All")
                        ttags = ttagPost(
                            '/find/url-keyword-hashtag', {
                                'query': form.getSpraycan_Search(),
                                'items_per_page': '100',
                                'page_number': '0'
                            })
                        response = {
                            'time': ttags['time'],
                            'data': {
                                'founder': {},
                                'favorite':
                                False,
                                'ttags': [] if filter not in ['All', 'Tags']
                                or ttags['data'] == None
                                or 'ttags' not in ttags['data']
                                or ttags['data']['ttags'] == None else
                                ttags['data']['ttags'],
                                'users': [] if filter not in ['All', 'Users']
                                or ttags['data'] == None
                                or 'users' not in ttags['data']
                                or ttags['data']['users'] == None else
                                ttags['data']['users'],
                                'hashtags':
                                [] if filter not in ['All', 'HashTags']
                                or ttags['data'] == None
                                or 'hashtags' not in ttags['data']
                                or ttags['data']['hashtags'] == None else
                                ttags['data']['hashtags'],
                                'location':
                                [] if filter not in ['All', 'Locations']
                                or ttags['data'] == None
                                or 'location' not in ttags['data']
                                or ttags['data']['location'] == None else
                                ttags['data']['location'],
                                'hubs': [] if filter not in ['All', 'Hubs']
                                or ttags['data'] == None
                                or 'hubs' not in ttags['data']
                                or ttags['data']['hubs'] == None else
                                ttags['data']['hubs'],
                                'spams': [],
                                'thumbups': []
                            }
                        }
                        from webapp.models.hub import processRawHubs
                        response['data']['hubs'] = processRawHubs(
                            response['data']['hubs'], request)
                        response['data']['followers'] = getUserFollowers(
                            loggedin_user)
                        from webapp.views.user import getUserHubs
                        response['data']['joinedhubs'] = getUserHubs(
                            data['user_name'])
                        response['data']['searchcounts'] = {
                            'ttags':
                            0 if ttags['data'] == None
                            or 'ttags' not in ttags['data']
                            or ttags['data']['ttags'] == None else len(
                                ttags['data']['ttags']),
                            'users':
                            0 if ttags['data'] == None
                            or 'users' not in ttags['data']
                            or ttags['data']['users'] == None else len(
                                ttags['data']['users']),
                            'hashtags':
                            0 if ttags['data'] == None
                            or 'hashtags' not in ttags['data']
                            or ttags['data']['hashtags'] == None else len(
                                ttags['data']['hashtags']),
                            'location':
                            0 if ttags['data'] == None
                            or 'location' not in ttags['data']
                            or ttags['data']['location'] == None else len(
                                ttags['data']['location']),
                            'hubs':
                            0 if ttags['data'] == None
                            or 'hubs' not in ttags['data']
                            or ttags['data']['hubs'] == None else len(
                                ttags['data']['hubs'])
                        }
                        servertime = datetime.datetime.fromtimestamp(
                            int(ttags['time']) / 1000)
                        if request.is_ajax():
                            thetemplate = 'base_ajax.html'
                        thereturn = render_to_response(
                            "spraycan.html",
                            locals(),
                            context_instance=RequestContext(request))
                    if request.is_ajax():
                        usercontext = mark_safe(
                            render_to_response('partial_user_details.html',
                                               locals(),
                                               context_instance=RequestContext(
                                                   request)).content)
                        import simplejson
                        jsonReturn = simplejson.dumps({
                            'context':
                            usercontext,
                            'results':
                            mark_safe(thereturn.content)
                        })
                        thereturn = HttpResponse(mark_safe(jsonReturn))
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
Exemplo n.º 6
0
def search(request):
    try :
        thereturn = loginscreen(request)
        loggedin, data = ttagServiceAuth(request)
        if loggedin :
            if 'search' in request.POST :
                atusername = ''
                emailform = SpraycanSearchEmail(request.POST)
                usernameform = SpraycanSearchUsername(request.POST)
                if emailform.is_valid() :
                    resp = ttagPost('/validate/request-username-by-email',{'email':emailform.getSpraycan_Search()})
                    if resp['result'] == 'OK' and resp['find_by_email'] :
                        atusername = resp['user_name']
                elif usernameform.is_valid() :
                    resp = ttagRequestUserProfile(usernameform.getSpraycan_Search()[1:])
                    if resp['result'] == 'OK' :
                        atusername = resp['data']['user_name']
                if atusername != '' :
    #                from django.core.urlresolvers import reverse
    #                return render_to_response("javascript_redirect.html", {"redirect_url" : reverse('user-profile', kwargs={'user_name':atusername,'view_type':'','page':'','time':''}),'hidespraycan':'true'})
                    from webapp.views.user import userWallView
                    return userWallView(request, atusername)
                form = SpraycanSearch(request.POST)
                if form.is_valid() :
                    urlform = SpraycanSearchURL(request.POST)
                    if urlform.is_valid() :
                        #show spraycan for URL
                        thereturn = url(request, urlform.getSpraycan_Search())
                    else :
                        #show search results
                        import datetime
                        from webapp.views.user import getUserFollowers
                        location_type = 'search'
                        loggedin_user = data['_id']
                        filter = request.POST.get('filter', "All")
                        ttags = ttagPost('/find/url-keyword-hashtag',{'query':form.getSpraycan_Search(),'items_per_page':'100','page_number':'0'})
                        response = {'time': ttags['time'], 'data':{
                                            'founder': {},
                                            'favorite': False,
                                            'ttags':[] if filter not in ['All','Tags'] or ttags['data'] == None or 'ttags' not in ttags['data'] or ttags['data']['ttags'] == None else ttags['data']['ttags'],
                                            'users': [] if filter not in ['All','Users'] or ttags['data'] == None or 'users' not in ttags['data'] or ttags['data']['users'] == None else ttags['data']['users'],
                                            'hashtags': [] if filter not in ['All','HashTags'] or ttags['data'] == None or 'hashtags' not in ttags['data'] or ttags['data']['hashtags'] == None else ttags['data']['hashtags'],
                                            'location': [] if filter not in ['All','Locations'] or ttags['data'] == None or 'location' not in ttags['data'] or ttags['data']['location'] == None else ttags['data']['location'],
                                            'hubs': [] if filter not in ['All','Hubs'] or ttags['data'] == None or 'hubs' not in ttags['data'] or ttags['data']['hubs'] == None else ttags['data']['hubs'],
                                            'spams':[],
                                            'thumbups':[]}}
                        from webapp.models.hub import processRawHubs
                        response['data']['hubs'] = processRawHubs(response['data']['hubs'], request)
                        response['data']['followers'] = getUserFollowers(loggedin_user)
                        from webapp.views.user import getUserHubs
                        response['data']['joinedhubs'] = getUserHubs(data['user_name'])
                        response['data']['searchcounts'] = {
                                                            'ttags': 0 if ttags['data'] == None or 'ttags' not in ttags['data'] or ttags['data']['ttags'] == None else len(ttags['data']['ttags']),
                                                            'users': 0 if ttags['data'] == None or 'users' not in ttags['data'] or ttags['data']['users'] == None else len(ttags['data']['users']),
                                                            'hashtags': 0 if ttags['data'] == None or 'hashtags' not in ttags['data'] or ttags['data']['hashtags'] == None else len(ttags['data']['hashtags']),
                                                            'location': 0 if ttags['data'] == None or 'location' not in ttags['data'] or ttags['data']['location'] == None else len(ttags['data']['location']),
                                                            'hubs': 0 if ttags['data'] == None or 'hubs' not in ttags['data'] or ttags['data']['hubs'] == None else len(ttags['data']['hubs'])
                                                            }
                        servertime = datetime.datetime.fromtimestamp(int(ttags['time'])/1000)
                        if request.is_ajax() :
                            thetemplate = 'base_ajax.html'
                        thereturn = render_to_response("spraycan.html", locals(), context_instance=RequestContext(request))
                    if request.is_ajax() :
                        usercontext = mark_safe(render_to_response('partial_user_details.html',locals(),context_instance=RequestContext(request)).content)
                        import simplejson
                        jsonReturn = simplejson.dumps({'context':usercontext,'results':mark_safe(thereturn.content)})
                        thereturn = HttpResponse(mark_safe(jsonReturn));
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)