Пример #1
0
def handle(request):
    myself = siteaction.getLoggedInUser(request)
    if not myself:
        return HttpResponseRedirect('/login.htm')

    page = dataplus.dictGetVal(request.REQUEST, 'page', 0, string.atoi)
    start_job_num = page * config.jobs_per_page
    last_job_num = start_job_num + config.jobs_per_page
    
    total_jobs = searchjobs.getMatchingJobsCount(myself)

    jobs = searchjobs.getMatchingJobs(myself, config.jobs_per_page, start_job_num)
    
    if total_jobs == 0:
        showing_howmany = '0 of 0 matching jobs'
    else:
        showing_howmany = str(start_job_num + 1) + '-' +  str(start_job_num + len(jobs)) + ' of ' + str(total_jobs)
    
    prev_btn = ''
    next_btn = ''
    if page != 0:
        prev_btn = '<td><input class="medium-btn" type="button" name="prev-button" value="PREV" onclick="javascript:window.location.href=\'matchingjobs.htm?page=' + str(page-1) + '\'" /></td>'
    if last_job_num < total_jobs:
        next_btn = '<td><input class="medium-btn" type="button" name="next-button" value="NEXT" onclick="javascript:window.location.href=\'matchingjobs.htm?page=' + str(page+1) + '\'" /></td>'

    buttons = prev_btn + next_btn
  
    return siteaction.render_to_response('me/matchingjobs.htm',
                              { 'interesting_jobs': jobs,
                                'showing_howmany': showing_howmany,
                                'buttons': buttons,
                                'myself' : myself })
Пример #2
0
def handle(request):
    myself = siteaction.getLoggedInUser(request)
    if not myself:
        return HttpResponseRedirect('/login.htm')
    
    if request.method == 'GET':
        return siteaction.render_to_response('me/searchjobs.htm', 
            {'showing_search_results': False,
             'myself': myself,
             'interesting': searchjobs.getMatchingJobs(myself)})
    elif request.method == 'POST':
        keywords = dataplus.dictGetVal(request.REQUEST,'keywords')
        
        if dataplus.dictGetVal(request.REQUEST,'action') == 'display':
            page = dataplus.dictGetVal(request.REQUEST,'page',0,string.atoi)
            
            pickled_match_list = dataplus.dictGetVal(request.REQUEST,'matches')
            match_list = cPickle.loads(str(pickled_match_list))
        else:
            keywords = keywords.strip()
            if keywords != '':
                match_list = searchjobs.getMatches(keywords)
                pickled_match_list = cPickle.dumps(match_list)
                page = 0
            else:
                return siteaction.render_to_response('me/searchjobs.htm', 
                    {'showing_search_results': True,
                     'myself': myself,
                     'message':'Please enter a valid search query.'})                
                
        start_num = page * config.job_matches_per_page
        end_num = ((page + 1) * config.job_matches_per_page)
        display_list = match_list[start_num:end_num]
        jobs_bulk_dict = models.JobPosition.objects.in_bulk(display_list)
        num_pages = ((len(match_list)-1)/config.job_matches_per_page) + 1
            
        matching_jobs = dataplus.getOrderedList(jobs_bulk_dict, display_list)
        
        if match_list:
            message = 'Showing ' + str(start_num + 1) + ' - ' + str(start_num + len(matching_jobs)) + ' of ' + str(len(match_list)) + ' matches.'
        else:
            message = 'Your search did not return any results.'
        
        return siteaction.render_to_response('me/searchjobs.htm', 
            {'matching_jobs': matching_jobs,
             'matches': cgi.escape(pickled_match_list),
             'page_links_html': getPageLinksHtml(num_pages, page),
             'keywords': keywords,
             'myself': myself,
             'showing_search_results': True})
Пример #3
0
def handle(request):
    myself = siteaction.getLoggedInUser(request)
    if not myself:
        return HttpResponseRedirect('/login.htm')
    
    if request.method == 'GET':
        #we have a valid user. need to update the mru_data
        mru_data = models.UserMRUData.objects.get(user__id=myself.id)    
            
        #get number of messages
        new_msgs_count = models.Message.objects.filter(account__id=myself.account.id, folder='inbox', 
            sent_at__gte=mru_data.last_accessed_time).count()

        has_requests, friend_req_html = getFriendReqBoxHtml(myself)
        myself.updateAccess()
        mru_data.last_accessed_time = datetime.datetime.utcnow()
        mru_data.save()
        
        action_result = ''
        if dataplus.dictGetVal(request.REQUEST, 'flashId'):
            action_result = dataplus.dictGetVal(statix.action_messages, dataplus.dictGetVal(request.REQUEST, 'flashId'), '')
        
        msgs = models.Message.objects.filter(account__id=myself.account.id, folder='inbox').order_by('-sent_at')[:6]
        last_message_id = 0
        if msgs:
            last_message_id = msgs[0].id
    
        return siteaction.render_to_response('me/index.htm',
                                  { 'friends_box_html': getFriendsBoxHtml(myself, request),
                                    'has_requests': has_requests,
                                    'friend_req_box_html' : friend_req_html,
                                    'community_box_html' : getCommBoxHtml(myself),
                                    'message_box_html': getMessageBoxHtml(msgs),
                                    'new_msgs_count': str(new_msgs_count),
                                    'profile_snapshot': getProfileSnapshotHtml(myself),
                                    'visitors_html':getVisitorsHtml(myself),
                                    'received_referrals':myself.received_referrals.all(),
                                    'matching_jobs':searchjobs.getMatchingJobs(myself, 5),
                                    'friends_count':myself.friends.count(),
                                    'last_message_id':last_message_id,
                                    'action_result':action_result,
                                    'myself' : myself })