Ejemplo n.º 1
0
def handle(request, username):
    username = username.lower()
    user = get_object_or_404(models.User, username=username)
    myself = siteaction.getLoggedInUser(request)
    
    if not canDownloadResume(user, myself):
        return siteaction.render_to_response('showmessage.htm', 
                                        {'msg_heading':'Access denied',
                                         'msg_html':'You do not have permissions to view this page.'})
                                        
    plain_resume = canViewPlainResume(user, myself)
    myself = siteaction.getLoggedInUser(request)
    type_pref = None
    if myself:
        if myself.username == user.username:
            type_pref = dataplus.dictGetVal(request.REQUEST, 'type')
                
    file_path = codejar_resume.getResumeFilePath(user, type_pref, not plain_resume)
    if not file_path:
        return HttpResponseNotFound('<h1>Page not found.</h1>')
    
    ext = os.path.splitext(file_path)[1].lower()
    read_type = {'.doc':'rb', '.pdf':'rb', '.odt':'rb', '.html':'r'}[ext]
    mime_type = {'.doc':'application/msword', '.pdf':'application/pdf', '.odt':'application/vnd.oasis.opendocument.text', '.html':'text/html'}[ext]
    
    file = open(file_path, read_type)
    filecontents = file.read()
    file.close()
    
    response = HttpResponse(filecontents, mimetype=mime_type)
    response['Content-Disposition'] = 'attachment; filename=' + user.username + ext
    
    return response
Ejemplo n.º 2
0
def handle(request, job_id):
    myself = siteaction.getLoggedInUser(request)
    if not myself:
        return HttpResponseRedirect('/login.htm')
    
    if not job_id:
        return siteaction.render_to_response('showmessage.htm', { 
                'msg_heading':'Error',
                'msg_html':'Access denied.'})
                
    job = dataplus.returnIfExists(models.JobPosition.objects.filter(id=job_id))
    if not job:
        return siteaction.render_to_response('showmessage.htm', { 
                'msg_heading':'Error',
                'msg_html':'Access denied.'})
    
    if job.posted_by:
        job.posted_by_name = job.posted_by.name
    elif job.tag:
        match = re.match('^.*name\=(?P<name>.*?);',job.tag)
        if match:
            job.posted_by_name = match.group('name')
        
    if request.method == 'GET':
        action_result = ''
        if dataplus.dictGetVal(request.REQUEST, 'flashId'):
            action_result = dataplus.dictGetVal(statix.action_messages, dataplus.dictGetVal(request.REQUEST, 'flashId'), '')
            
        if job.min_compensation == job.max_compensation:
            job.salary = str(job.min_compensation)
        else:
            job.salary = str(job.min_compensation) + ' - ' + str(job.max_compensation)
        return siteaction.render_to_response('jobs/viewjobposition.htm',
                            { 'myself': myself,
                              'job':job,
                              'action_result':action_result,
                            })
    elif request.method == 'POST':
        html_message = '<p>Hello ' + job.posted_by_name + ',</p><p>This is in reference to the job you posted titled "' + job.title + '" for ' + job.company_name + '. ' + \
                    'I would like to apply for this position and you can find my resume as an attachment.</p><p>You can always download my latest resume from ' + \
                    '<a href="' + config.server_base_url + config.profiles_url + '/' + myself.username + '">my profile</a>.</p>' + \
                    '<p>Regards,<br />' + myself.name + '</p><br /><br /><br /><br /><br /><br />'+ \
                    'Don\'t want to receive email alerts? Just change your <a href="' + config.server_base_url +  \
                    '/me/editsettings.htm">Email Forwarding Settings</a>'
                    
        text_message = 'Hello ' + job.posted_by_name + ',\r\nThis is in reference to the job you posted titled "' + job.title + '" for ' + job.company_name + '. ' + \
                    'I would like to apply for this position and you can find my resume as an attachment.\r\nYou can always download my latest resume from my profile at ' + \
                    config.server_base_url + config.profiles_url + '/' + myself.username + '.\r\n' + \
                    'Regards,\r\n' + myself.name + '\r\n\r\n\r\n\r\n\r\n\r\n' + + \
                    'Don\'t want to receive email alerts? Just change your Email Forwarding Settings, visit - "' +  \
                    config.server_base_url + '/me/editsettings.htm"'
                    
        resume_file = codejar_resume.getResumeFilePath(myself)
        mailman.sendMail('"' + myself.name + '" <' + myself.username + '*****@*****.**>', [job.contact_email], 'Re: Job Posting - ' + job.title, html_message, [resume_file], None, text_message, reply_to=myself.email)

        return HttpResponseRedirect('/jobs/' + str(job.id) + '/?flashId=resume_fwd')
Ejemplo n.º 3
0
def handle(request):
    myself = siteaction.getLoggedInUser(request)  
    if not myself:
        return HttpResponseRedirect('/login.htm?' + urllib.urlencode(
                {'returnUrl':'/me/viewreferral.htm?id=' + dataplus.dictGetVal(request.REQUEST, 'id', '')}))
    
    req_id = dataplus.dictGetVal(request.REQUEST, 'id', 0, string.atoi)
    if req_id > 0:
        referral = models.JobReferral.objects.get(id=req_id)
    
    if request.method == 'GET':
        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/viewreferral.htm', 
                                    {'referral':referral,
                                    'action_result':action_result,
                                    'myself':myself})
    elif request.method == 'POST':
        html_message = '<p>Hi,</p><p>This is in reference to the job opening "' + referral.subject + '". ' + \
                    'I would like to apply for this position and you can find my resume as an attachment.</p><p>You can always download my latest resume from ' + \
                    '<a href="' + config.server_base_url + config.profiles_url + '/' + myself.username + '">my profile</a>.</p>' + \
                    '<p>Regards,<br />' + myself.name + '</p><br /><br /><br /><br /><br /><br />'+ \
                    'Don\'t want to receive email alerts? Just change your <a href="' + config.server_base_url +  \
                    '/me/editsettings.htm">Email Forwarding Settings</a>'
                    
        text_message = 'Hi,\r\nThis is in reference to the job opening "' + referral.subject + '". ' + \
                    'I would like to apply for this position and you can find my resume as an attachment.\r\nYou can always download my latest resume from my profile at ' + \
                    config.server_base_url + config.profiles_url + '/' + myself.username + '.\r\n' + \
                    'Regards,\r\n' + myself.name + '\r\n\r\n\r\n\r\n\r\n\r\n' + + \
                    'Don\'t want to receive email alerts? Just change your Email Forwarding Settings, visit - "' +  \
                    config.server_base_url + '/me/editsettings.htm"'   
                                    
        resume_file = codejar_resume.getResumeFilePath(myself)
        mailman.sendMail('"' + myself.name + '" <' + myself.username + '*****@*****.**>', [referral.reply_to_email], 'Re: Referral - ' + referral.subject, html_message, [resume_file], None, text_message, reply_to=myself.email)

        return HttpResponseRedirect('/me/viewreferral.htm?id=' + str(req_id) + '&amp;flashId=resume_fwd')