예제 #1
0
def handle(request):
    myself = siteaction.getLoggedInUser(request, True)
    if not myself:
        return HttpResponseRedirect('/login.htm')
    
    action_id, random_key = codejar_invites.getInviteData(request)
    if not action_id:
        return HttpResponseRedirect('/me/')
    
    invitation = action_id + '=' + random_key
    
    if myself.account.account_state == 'I':
        post_signup_actions = dataplus.returnIfExists(models.PostSignupActions.objects.filter(user=myself))
        if not post_signup_actions:
            post_signup_actions = models.PostSignupActions(user=myself)
        
        if post_signup_actions.actions:
            post_signup_actions.actions += ',' + invitation
        else:
            post_signup_actions.actions = invitation
        
        post_signup_actions.save()
        
        return HttpResponseRedirect('/me/createresume.htm')
    
    else:
        success, response = codejar_invites.processInvitations(myself, [invitation])
        return response  
예제 #2
0
def handle(request):
    myself = siteaction.getLoggedInUser(request, True)
    if not myself:
        return HttpResponseRedirect('/login.htm')
    
    if not myself.resume_contents.text:
        return HttpResponseRedirect('createresume.htm')
    
    if request.method == 'GET':
        settings = models.UserSettings.objects.get(user=myself)
        
        industry_cats = models.IndustryCategory.objects.all().order_by('id')
        industry_cats_html = hotmetal.elemSelect([('Select', '')], industry_cats,
            lambda x:x.name, lambda x:x.name, '', 'name="industry_category" id="industry_category" style="width:320px"')  
        
##        locations = models.Location.objects.all().order_by('name')
##        preferred_location = hotmetal.elemSelect([('Select', ''),('Anywhere', 'Anywhere')], locations,
##            lambda x:x.name, lambda x:x.name, '', 'name="preferred_location" id="preferred_location" style="width:160px"')  
        
##        salary_ranges = statix.getSalaryRanges()
##        salary_range_select_html = hotmetal.elemSelect([('Select', '0-0'),('Prefer not to say', '0-0')], salary_ranges,
##            lambda x:x[1], lambda x:x[0], '0-0', 'name="salary_range" id="salary_range" style="width:160px"')   

        salary_ranges = codejar_resume.getSalaryRanges(settings.country)
        salary_range_select_html = hotmetal.elemSelect([('Select', '0-0'),('Prefer not to say', '0-0')], salary_ranges,
            lambda x:x[1], lambda x:x[0], '0-0', 'name="salary_range" id="salary_range" style="width:160px"') 
        salary_range_select_html += '(' + settings.currency + ')'

        experience_select_html = hotmetal.elemSelect([('Select', '-1')], range(0,51),
            lambda x:x, lambda x:x, '', 'name="experience" id="experience" style="width:90px"')  
    
        settings = models.UserSettings.objects.get(user=myself)
        interest_in_new_job = hotmetal.elemSelect([('Interested', 'active'),
            ('Only Terrific! Offers', 'passive'), ('Not Interested', 'no')], [],
                None, None, settings.interest_in_new_job, 'name="interest_in_new_job" id="interest_in_new_job" style="width:160px"')
                
        resume_visibility = hotmetal.elemSelect([('Everyone', 'everyone'), ('Friends only', 'friends'), ('Nobody', 'nobody')], [],
            None, None, settings.resume_visibility, 'name="resume_visibility" id="resume_visibility" style="width:120px"')            
            
        action_result = ''
        if dataplus.dictGetVal(request.REQUEST, 'flashId'):
            action_result = dataplus.dictGetVal(statix.action_messages, dataplus.dictGetVal(request.REQUEST, 'flashId'), '')
            
        return siteaction.render_to_response('me/createjobsettings.htm',
            {'industry_categories_html': industry_cats_html,
            'experience_select_html':experience_select_html,
            'salary_range_select_html':salary_range_select_html,
##            'preferred_location':preferred_location,
            'resume_visibility':resume_visibility, 
            'interest_in_new_job': interest_in_new_job, 
            'action_result':action_result,
            'myself': myself})
    
    elif request.method == 'POST':
        try:
            str_industry_category = dataplus.dictGetVal(request.REQUEST,'industry_category')
            industry_category = models.IndustryCategory.objects.get(name=str_industry_category)
            myself.industry_category = industry_category
            
            myself.working_since = datetime.datetime.utcnow() - datetime.timedelta(dataplus.dictGetVal(request.REQUEST,'experience',0,string.atoi) * 365)
            
            #salary in the format 'min_salary-max_salary'
            #this string needs to be split into min and max
            sal_range = dataplus.dictGetVal(request.REQUEST,'salary_range').split('-')
            myself.salary_range_lower = string.atoi(sal_range[0])
            myself.salary_range_upper = string.atoi(sal_range[1])        
            
            myself.phone = dataplus.dictGetVal(request.REQUEST,'phone')
            
            settings = models.UserSettings.objects.get(user=myself)
            settings.resume_visibilty = dataplus.dictGetVal(request.REQUEST,'resume_visibilty')
            settings.interest_in_new_job = dataplus.dictGetVal(request.REQUEST,'interest_in_new_job')
            settings.preferred_location = 'Anywhere'
##            settings.preferred_location = dataplus.dictGetSafeVal(request.REQUEST,'preferred_location')
                    
            myself.last_update_time = datetime.datetime.utcnow()
            myself.save() 
            settings.save()
            myself.account.account_state = 'A'
            myself.account.save()

            redirect_url = ''
            post_signup_actions = dataplus.returnIfExists(models.PostSignupActions.objects.filter(user=myself))
            if post_signup_actions:
                actions = post_signup_actions.actions.split(',')
                success, response = codejar_invites.processInvitations(myself, actions)
                if response:
                    return response            
        except:
            return HttpResponseRedirect('createjobsettings.htm?flashId=failed_jobset_save')
                
        return HttpResponseRedirect('/me/')
예제 #3
0
def handle(request):
    action_id = ''
    random_key = ''
    if dataplus.dictGetVal(request.REQUEST, 'inviteId'):
        action_id = 'inviteId'
        random_key = dataplus.dictGetVal(request.REQUEST, 'inviteId')
    elif dataplus.dictGetVal(request.REQUEST, 'commInviteId'):
        action_id = 'commInviteId'
        random_key = dataplus.dictGetVal(request.REQUEST, 'commInviteId')
    elif dataplus.dictGetVal(request.REQUEST, 'commFriendInviteId'):
        action_id = 'commFriendInviteId'
        random_key = dataplus.dictGetVal(request.REQUEST, 'commFriendInviteId')
    
    if not action_id:
        return HttpResponseRedirect('/')
    
    username = dataplus.dictGetVal(request.REQUEST, 'user')
    if username:        
        myself = siteaction.getLoggedInUser(request)
        if myself and myself.username == username:
            success, response = codejar_invites.processInvitations(myself, [action_id + '=' + random_key])
            return response
        else:
            siteaction.doLogout(request)
    
    if action_id == 'inviteId':
        friend_invite = dataplus.returnIfExists(models.FriendInvitation.objects.filter(invite_random_key=random_key))
    elif action_id == 'commInviteId':
        comm_invite = dataplus.returnIfExists(models.CommunityInvitation.objects.filter(invite_random_key=random_key))
    elif action_id == 'commFriendInviteId':
        friend_invite = dataplus.returnIfExists(models.FriendInvitation.objects.filter(invite_random_key=random_key))
        comm_invite = dataplus.returnIfExists(models.CommunityInvitation.objects.filter(invite_random_key=random_key))
    
    invited_by = None
    if action_id == 'inviteId' or action_id == 'commFriendInviteId':
        if friend_invite:
            invited_by = friend_invite.sent_by
            invited_by.image_url = dataplus.getStaticUrl(invited_by.image_size3_file_path)
        else:
            return HttpResponseRedirect('/login.htm')   ##TODO: Have to show a better response that invite doesn't exist
    
    if action_id == 'commInviteId' or action_id == 'commFriendInviteId':
        if comm_invite:
            invited_by = comm_invite.sent_by
            invited_by.image_url = dataplus.getStaticUrl(invited_by.image_size3_file_path)
            invited_comm = comm_invite.community
            invited_comm.image_url = dataplus.getStaticUrl(invited_comm.image_size3_file_path)
        else:
            return HttpResponseRedirect('/login.htm')   ##TODO: Have to show a better response that invite doesn't exist
    
    welcome_text = 'You have been invited to join Socialray by '+ invited_by.name + '. Socialray is a ' + \
        'Professional Networking site, where you can showcase your skills and expertise, ' + \
        'stay in touch with friends and colleagues, and a lot more. Come onboard, and find out!'
    
##    welcome_text = {'inviteId':'You were invited to join Socialray by ' + invited_by.name + '.',
##                    'commInviteId':'You were invited to join ' + invited_comm.name + ' by ' + invited_by.name + '.',
##                    'commFriendInviteId':'You were invited to join ' + invited_comm.name + ' by ' + invited_by.name + '.'}[action_id]
    
    login_url = '/login.htm?returnUrl=' + cgi.escape('/me/processinvites.htm?' + action_id + '=' + random_key)
    return siteaction.render_to_response('me/acceptinvite.htm', 
                                {'welcome_text':welcome_text,
                                'invited_by':invited_by,
                                'invited_comm':invited_comm,
                                'signup_url':'/me/signup.htm?' + action_id + '=' + random_key,
                                'login_url':login_url,
                                'invited_by_text':dataplus.getPreviewText(invited_by.hilite,500)})