예제 #1
0
def handle(request):
    import website.bigfoot.models as models
    zoomo_id = dataplus.dictGetVal(request.REQUEST, 'zid')
    hresume_contents = get_object_or_404(models.HResumeContents, zoomo_id=zoomo_id)
    
    if request.method == 'GET':      
        return render_to_response('resumitypublish.htm', 
            {'zid':zoomo_id})
    
    #Handles only post requests
    elif request.method == 'POST':
        html = hresume_contents.resume
        
        action = dataplus.dictGetSafeVal(request.REQUEST, 'action')
        user = None
        from website.bigfoot.utils import siteaction, codejar_resume, sessions_client, livewire_client
        if action == 'new_publish':
            username = dataplus.dictGetSafeVal(request.REQUEST, 'new_username')
            password1 = dataplus.dictGetSafeVal(request.REQUEST, 'password1')
            password2 = dataplus.dictGetSafeVal(request.REQUEST, 'password2')
            industry_category = hresume_contents.industry_category.name
            posted_data = simplejson.loads(base64.b64decode(hresume_contents.post_dict))
            experience = calculateExperience(posted_data)
            country = models.Country.objects.get(name=hresume_contents.country)
            
            full_name = (hresume_contents.fname + ' ' + hresume_contents.lname).strip()
            
            user = siteaction.createUser(username, full_name, password1, hresume_contents.email, country.code, industry_category, experience)
            session_id = sessions_client.query('addNewSession', [user.username])
        elif action == 'login_publish':
            username = dataplus.dictGetSafeVal(request.REQUEST, 'username')
            password = dataplus.dictGetSafeVal(request.REQUEST, 'password')
            success, session_id, url, info = siteaction.doAjaxLogin(username, password)
            if not success:
                return render_to_response('resumitypublish.htm', 
                    {'zid':zoomo_id,
                    'error_text': info})
            else:
                user = models.User.objects.get(username=username)
                
        html_body = html[html.index('<body>')+len('<body>'):html.index('</body>')]
        codejar_resume.saveResume(user, html_body)
        useraccount = user.account
        
        hresume_contents = models.HResumeContents.objects.get(zoomo_id=zoomo_id)
        hresume_contents.account = useraccount
        hresume_contents.save()

        if session_id:
            chat_settings = models.ChatSettings.objects.get(account=useraccount)
            livewire_client.command('updateUserSession', [session_id, useraccount.username, useraccount.name, chat_settings.online_status, 
                chat_settings.custom_message, chat_settings.invite_preference, chat_settings.ignore_list, 
                dataplus.getSocialrayStaticUrl(chat_settings.image_size1_file_path), dataplus.getSocialrayStaticUrl(chat_settings.image_size2_file_path), 
                dataplus.getSocialrayStaticUrl(chat_settings.image_size3_file_path)])
        
        return siteaction.redirectWithCookie('/me/', 'session_id', session_id)
예제 #2
0
def saveResumeDoc(user, resume_dir, ext='.doc'):
    try:        
        html_created, html_formatter = codejar_resume.convertToXHtml(user, resume_dir + '/' + user.username + ext, resume_dir, ext)        
        if not html_created:
            return False, 'cannot_create_html'
        
        html_body, html_style = codejar_resume.extractBodyAndStyle(resume_dir + '/' + user.username + '.html', html_formatter)
        
        save_result = codejar_resume.saveResume(user, html_body, html_style, html_formatter, False)
        
        if save_result:
            format = ext[1:]
            settings = models.UserSettings.objects.get(user=user)
            settings.original_resume_format = format
            settings.available_resume_download_formats = 'html'
            if not settings.resume_download_format_set:
                if format == 'doc':
                    settings.preferred_resume_download_format = 'doc'
                elif format == 'odt':
                    settings.preferred_resume_download_format = 'pdf'
            settings.save()
            return True, 'ok'
        else:
            return False, 'unknown'
    except:
        return False, 'unknown'
예제 #3
0
def process():
    users = models.User.objects.all().order_by('id')
    for user in users:
        old_path = user.resume_dir + '/' + user.username + '.htm'
        new_path = user.resume_dir + '/' + user.username + '.html'
        if os.path.exists(old_path):
            shutil.move(old_path, new_path)
        
        if user.resume_dir:
            if not os.path.exists(user.resume_dir):
                print 'resume_dir missing.. creating...'
                os.mkdir(user.resume_dir)
                
        try:
            settings = models.UserSettings.objects.get(user=user)
        except:
            print 'user settings missing.. creating...'
            settings = models.UserSettings()
            settings.email_fwd_messages = False
            settings.email_fwd_jobrefs = True
            settings.email_fwd_alerts = True
            settings.phone_num_visibility = 'friends'
            settings.resume_visibility = 'everyone'
            settings.interest_in_new_job = 'active'
            settings.preferred_location = 'Anywhere'
            settings.original_resume_format = 'html'
            settings.available_resume_download_formats = ''
            settings.preferred_resume_download_format = 'pdf'
            settings.resume_download_format_set = False
            settings.user = user
            settings.save()
        
        try:
            matching_jobs = models.MatchingJobs.objects.get(user=user)
        except:
            print 'matching jobs missing.. creating...'
            matching_jobs = models.MatchingJobs()
            matching_jobs.user = user
            matching_jobs.jobs = ''
            matching_jobs.save()
        
        try:
            mru_data = models.UserMRUData.objects.get(user=user)
        except:
            print 'mru data missing.. creating...'
            mru_data = models.UserMRUData()
            mru_data.last_accessed_time = datetime.datetime.utcnow()
            mru_data.user = user
            mru_data.save()
            
        success = False
        error_code = ''        
        if settings.original_resume_format == 'doc':
            success, error_code = saveResumeDoc(user, user.resume_dir)
        elif settings.original_resume_format == 'html':
            error_code = ''
            success = codejar_resume.saveResume(user, user.resume_contents.text, original=False)
        
        print success, error_code, user.id, user.name
예제 #4
0
def handle(request):
    myself = siteaction.getLoggedInUser(request, True)
    if not myself:
        return HttpResponseRedirect('/login.htm')
    
    if request.method == 'GET':
        hide_fill_profile_pic = False
        action_result = ''
        if dataplus.dictGetVal(request.REQUEST, 'flashId'):
            action_result = dataplus.dictGetVal(statix.action_messages, dataplus.dictGetVal(request.REQUEST, 'flashId'), '')
            hide_fill_profile_pic = True
        revisit = (dataplus.dictGetVal(request.REQUEST, 'action') == 'revisit')
            
        return siteaction.render_to_response('me/createresume.htm',
            {   'resume_contents' : codejar_resume.getResumeText(myself),
                'action_result':action_result,
                'hide_fill_profile_pic':hide_fill_profile_pic,
                'revisit':revisit,
                'myself': myself})
    
    elif request.method == 'POST':
        if dataplus.dictGetVal(request.REQUEST,'action') == 'upload':
            if not (request.FILES and request.FILES.getlist('resume_doc')[0]['filename'].lower().endswith('.doc')):
                return HttpResponseRedirect('createresume.htm?flashId=invalid_doc_upload')
            
            success, error_code = codejar_resume.saveResumeDoc(myself, request, 'resume_doc')
            if not success:
                return HttpResponseRedirect('createresume.htm?flashId=' + error_code)
            
        elif dataplus.dictGetVal(request.REQUEST,'action') == 'save':
            try:
                resumetext = dataplus.dictGetVal(request.REQUEST,'resumetext')
                codejar_resume.saveResume(myself, resumetext)
                myself.save()
            except:
                return HttpResponseRedirect('createresume.htm?flashId=failed_res_save')
        
        return HttpResponseRedirect('createjobsettings.htm')
예제 #5
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')
예제 #6
0
def createUser(username, password, name, email, industry_category):
    if (models.Account.objects.filter(username=username).count() > 0):
        return None
    
    now = datetime.datetime.utcnow()
    
    account = models.Account()
    account.username = username
    account.password = dataplus.hash(password)
    account.account_type = 'U'
    account.account_state = 'A'
    account.name = name
    account.email = email
    account.save()
    
    user = models.User()
    user.account = account
    user.username = username
    user.name = name
    user.email = email
    user.resume_update_time = now
    user.image_size1_file_path = '/apps/socialray/website/bigfoot/ui/files/images/' + username + '-p1.jpg'
    user.image_size2_file_path = '/apps/socialray/website/bigfoot/ui/files/images/' + username + '-p2.jpg'
    user.image_size3_file_path = '/apps/socialray/website/bigfoot/ui/files/images/' + username + '-p3.jpg'
    user.image_file_path = '/apps/socialray/website/bigfoot/ui/files/images/' + username + '.jpg'
    user.last_access_time = now
    user.last_update_time = now
    
    resume_contents = models.ResumeContents()
    resume_contents.text = ''
    resume_contents.save()
    user.resume_contents = resume_contents
    
    user.personal_desc = ''
    user.small_desc = ''
    user.blog_url = ''
    user.hilite = ''
    user.resume_dir = ''
    
    user.industry_category = industry_category
    
    codejar_resume.updatePlainTextResume(user)
    
    user.save()
    
    resume_text = '"After all the fuss over the AACS trying to censor a certain 128-bit number ' + \
        'that now has something over two million hits on Google, the folks at Freedom to Tinker ' + \
        'would like to point out that you too can own your own integer. They\'ve set up a script' + \
        ' that will generate a random number, encrypt a copyrighted haiku with it, and then deed' + \
        ' the number back to you. You won\'t get a copyright on the number or the haiku, but your' + \
        ' number has become an illegal circumvention device under the DMCA, such that anyone subject' + \
        ' to US law caught distributing it can be punished under the DMCA\'s anti-trafficking section,' + \
        ' for which the DMCA\'s Safe Harbor provisions do not apply. So F9090211749D5BE341D8C5565663C088 ' + \
        'is truly mine now, and you can pry it out of my cold, dead fingers!"'
        
    codejar_resume.saveResume(user, resume_text, '')
    
    settings = models.UserSettings()
    settings.email_fwd_messages = False
    settings.email_fwd_jobrefs = True
    settings.email_fwd_alerts = True
    settings.phone_num_visibility = 'all'
    settings.user = user
    settings.save()
    
    matching_jobs = models.MatchingJobs()
    matching_jobs.user = user
    matching_jobs.save()

    mru_data = models.UserMRUData()
    mru_data.last_accessed_time = now
    mru_data.user = user
    mru_data.save()
    
    return user