def handle(request):    
    if request.method == 'GET':
        #there cannot be get requests to this page.....
        return siteaction.render_to_response('showmessage.htm', 
            {'msg_heading': 'Error',
              'msg_html': 'Invalid URL'})
    
    elif request.method == 'POST':
        if (dataplus.dictGetVal(request.REQUEST,'action') == 'page2'):
            industry_cat = dataplus.dictGetVal(request.REQUEST,'industry_category')
            
            if not (dataplus.dictGetVal(request.REQUEST,'postedby') and dataplus.dictGetVal(request.REQUEST,'industry_category') \
                and dataplus.dictGetVal(request.REQUEST,'company')  and dataplus.dictGetVal(request.REQUEST,'location') \
                and dataplus.dictGetVal(request.REQUEST,'phone') and dataplus.dictGetVal(request.REQUEST,'email')):
                return siteaction.render_to_response('showmessage.htm', {'msg_heading':'Invalid request', \
                    'msg_html':'Required fields were not supplied. Please fill all the required fields and try again.'})
                    
            salary_ranges = codejar_resume.getSalaryRanges(dataplus.dictGetVal(request.REQUEST,'country'))
            salary_range_select_html = hotmetal.elemSelect([('Select', '0-0')], salary_ranges,
                lambda x:x[1], lambda x:x[0], '0-0', 'name="salary_range" id="salary_range" style="width:160px"')
            currency_code = models.Country.objects.get(code=dataplus.dictGetVal(request.REQUEST,'country')).currency_code
            
            return siteaction.render_to_response('recruiters/postjobsnow2.htm',
                {'postedby': dataplus.dictGetVal(request.REQUEST,'postedby'),
                 'industry_category': cgi.escape(dataplus.dictGetVal(request.REQUEST,'industry_category')),
                 'company': dataplus.dictGetVal(request.REQUEST,'company'),
                 'location': dataplus.dictGetVal(request.REQUEST,'location'),
                 'country': dataplus.dictGetVal(request.REQUEST,'country'),
                 'email': dataplus.dictGetVal(request.REQUEST,'email'),
                 'phone': dataplus.dictGetVal(request.REQUEST,'phone'),
                 'salary_range_select_html': salary_range_select_html,
                 'currency_code':currency_code,
                 'cid':dataplus.getUniqueId(),})

        elif (dataplus.dictGetVal(request.REQUEST,'action') == 'save'):
            if dataplus.dictGetVal(request.REQUEST,'captcha_text') != request.session['postjob_captcha_text']:
                return siteaction.render_to_response('recruiters/postjobsnow2.htm',
                    {'postedby': dataplus.dictGetVal(request.REQUEST,'postedby'),
                     'industry_category': cgi.escape(dataplus.dictGetVal(request.REQUEST,'industry_category')),
                     'company': dataplus.dictGetVal(request.REQUEST,'company'),
                     'location': dataplus.dictGetVal(request.REQUEST,'location'),
                     'country': dataplus.dictGetVal(request.REQUEST,'country'),
                     'email': dataplus.dictGetVal(request.REQUEST,'email'),
                     'phone': dataplus.dictGetVal(request.REQUEST,'phone'),
                     'designation': dataplus.dictGetVal(request.REQUEST,'designation'),
                     'jobdescription': dataplus.dictGetVal(request.REQUEST,'jobdescription'),
                     'location': dataplus.dictGetVal(request.REQUEST,'location'),
                     'exact_salary': dataplus.dictGetVal(request.REQUEST,'exact_salary'),
                     'mandatory_skills': dataplus.dictGetVal(request.REQUEST,'mandatory_skills'),
                     'desired_skills': dataplus.dictGetVal(request.REQUEST,'desired_skills'),
                     'title': dataplus.dictGetVal(request.REQUEST,'title'),
                     'error_html':'<p class="error-note">The captcha(verification) text entered doesn\'t match.</p>'})
            
            job_pos = models.JobPosition()
            job_pos.tag = 'name=' + dataplus.dictGetSafeVal(request.REQUEST, 'postedby') + ';'
            job_pos.company_name = dataplus.dictGetSafeVal(request.REQUEST, 'company')
                    
            industry_category = models.IndustryCategory.objects.get(name=dataplus.dictGetVal(request.REQUEST,'industry_category'))
            job_pos.industry_category = industry_category
            
            job_pos.designation = dataplus.dictGetSafeVal(request.REQUEST, 'designation')
            job_pos.job_description = dataplus.dictGetSafeVal(request.REQUEST, 'jobdescription','')
            job_pos.num_positions = 1 #one for now.
            job_pos.closing_date = config.max_date
            job_pos.location = dataplus.dictGetSafeVal(request.REQUEST, 'location')
            job_pos.country = dataplus.dictGetSafeVal(request.REQUEST, 'country')
            
            exact_salary = dataplus.dictGetVal(request.REQUEST,'exact_salary')
            if exact_salary:
                exact_salary = string.atoi(exact_salary)
                job_pos.min_compensation = exact_salary
                job_pos.max_compensation = exact_salary
            else:            
                #salary in the format 'min_salary-max_salary'
                #this string needs to be split into min and max
                sal = string.split(dataplus.dictGetVal(request.REQUEST,'salary_range'),'-')
                job_pos.min_compensation = string.atoi(sal[0])
                job_pos.max_compensation = string.atoi(sal[1])
            
            job_pos.min_exp_years = dataplus.dictGetVal(request.REQUEST,'min_exp_years',0)
            job_pos.mandatory_skills = dataplus.dictGetSafeVal(request.REQUEST, 'mandatory_skills')
            job_pos.desired_skills = dataplus.dictGetSafeVal(request.REQUEST, 'desired_skills')
            job_pos.educational_qualifications = dataplus.dictGetSafeVal(request.REQUEST,'edu_qualifications')
            job_pos.contact_email = dataplus.dictGetSafeVal(request.REQUEST,'email')
            job_pos.contact_phone = dataplus.dictGetSafeVal(request.REQUEST,'phone')
            if dataplus.dictGetVal(request.REQUEST,'title') != '':
                job_pos.title = dataplus.dictGetSafeVal(request.REQUEST,'title')
            else:
                job_pos.title = (job_pos.designation + ' - ' + job_pos.mandatory_skills + ' (' + str(job_pos.min_exp_years) + ' years)')[:30] + '...'
            
            job_pos.currency = config.default_currency
            job_pos.url = ''
            
            job_pos.save()
            
            return siteaction.render_to_response('showmessage.htm', 
                                    { 'msg_heading':'Success',
                                       'msg_html':'The job was added successfully. <a href="/recruiters/postjobsnow1.htm">Add Another</a>.'})
Exemplo n.º 2
0
def handle(request):
    myself = siteaction.getLoggedInUser(request)
    if not myself:
        return HttpResponseRedirect('/login.htm')
    
    settings = models.UserSettings.objects.get(user=myself)
    if request.method == 'GET':
        action_result = ''
        if dataplus.dictGetVal(request.REQUEST, 'flashId'):
            action_result = dataplus.dictGetVal(statix.action_messages, dataplus.dictGetVal(request.REQUEST, 'flashId'), '')
        
        experience_select_html = ''
        diff_years = None
        if myself.working_since != None:
            diff_years = (datetime.datetime.utcnow() - myself.working_since).days/365        
        experience_select_html = hotmetal.elemSelect([('Select', '-1')], range(0,30),
            lambda x:x, lambda x:x, diff_years, 'name="experience" id="experience" style="width:90px"')
        
        curr_range = str(myself.salary_range_lower) + '-' + str(myself.salary_range_upper)  
        salary_ranges = codejar_resume.getSalaryRanges(settings.country)
        salary_range_select_html = hotmetal.elemSelect([('Prefer not to say', '0-0')], salary_ranges,
            lambda x:x[1], lambda x:x[0], curr_range, 'name="salary_range" id="salary_range" style="width:160px"')
        salary_range_select_html += '(' + settings.currency + ')'
      
##        salary_ranges = statix.getSalaryRanges()
##        salary_range_select_html = hotmetal.elemSelect([('Prefer not to say', '0-0')], salary_ranges,
##            lambda x:x[1], lambda x:x[0], curr_range, 'name="salary_range" id="salary_range" style="width:160px"')
##        
##        locations = models.Location.objects.all().order_by('name')
##        preferred_location = hotmetal.elemSelect([('Select', ''),('Anywhere', 'Anywhere')], locations,
##            lambda x:x.name, lambda x:x.name, settings.preferred_location, 'name="preferred_location" id="preferred_location" style="width:160px"')
        
        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"')
        
        format_list = []
        selected_format = ''
        if not settings.resume_download_format_set:
            format_list = [('Select',''),('PDF', 'pdf'),('HTML', 'html'),('Word Doc', 'doc')]
        else:
            format_list = [('PDF', 'pdf'),('HTML', 'html'),('Word Doc', 'doc')]
            selected_format = settings.preferred_resume_download_format
        
        preferred_resume_download_format = hotmetal.elemSelect(format_list,
                [], None, None, selected_format, 'name="preferred_resume_download_format" id="preferred_resume_download_format" style="width:120px"')
        
        return siteaction.render_to_response('me/editresume.htm',
            {   'resume_contents' : codejar_resume.getResumeText(myself),
                'has_doc_resume':(settings.original_resume_format == 'doc'),
                'has_odt_resume':(settings.original_resume_format == 'odt'),
                'industry_categories_html': codejar_resume.getIndustryCategoriesHtml(myself),
                'experience_select_html':experience_select_html,
                'salary_range_select_html' : salary_range_select_html,
##                'preferred_location':preferred_location,
                'interest_in_new_job': interest_in_new_job, 
                'html_style':myself.resume_contents.html_style,
                'action_result':action_result,
                'preferred_resume_download_format':preferred_resume_download_format,
                'myself': myself})                
    
    elif request.method == 'POST':
        if dataplus.dictGetVal(request.REQUEST,'action') == 'upload':
            success, error_code = codejar_resume.saveResumeDoc(myself, request, 'resume_doc')
            if not success:
                return HttpResponseRedirect('/me/editresume.htm?flashId=' + error_code)
            
            return HttpResponseRedirect('/profiles/' + myself.username + '?flashId=res_uploaded')
##            return HttpResponseRedirect('/me/editresume.htm?flashId=res_uploaded')
            
        elif dataplus.dictGetVal(request.REQUEST,'action') == 'save':
            resumetext = dataplus.dictGetVal(request.REQUEST,'resumetext')
            success = codejar_resume.saveResume(myself, resumetext)
            if not success:
                return HttpResponseRedirect('/me/editresume.htm?flashId=cannot_create_html')
            
            return HttpResponseRedirect('/me/editresume.htm?flashId=res_saved')
            
        elif dataplus.dictGetVal(request.REQUEST,'action') == 'profilesettings':
            #save industry_category
            str_industry_cat = dataplus.dictGetVal(request.REQUEST,'industry_category')
            industry_category = models.IndustryCategory.objects.get(name=str_industry_cat)
            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])
##            
##            settings.preferred_location = dataplus.dictGetSafeVal(request.REQUEST,'preferred_location')
            settings.interest_in_new_job = dataplus.dictGetVal(request.REQUEST,'interest_in_new_job')
            preferred_format = dataplus.dictGetVal(request.REQUEST,'preferred_resume_download_format')
            if preferred_format != '':
                settings.preferred_resume_download_format = preferred_format
                settings.resume_download_format_set = True
            
            settings.save()
            myself.save()
        
            return HttpResponseRedirect('/me/editresume.htm?flashId=prof_set_saved')
Exemplo n.º 3
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/')