コード例 #1
0
def addRecruiter(email, name, organization):

    print("creating Recruiter " + email + " " + name + " " + organization)

    account = models.Account()
    account.username = email
    account.password = dataplus.hash(dataplus.getUniqueId())
    account.account_type = "FR"
    account.account_state = "I"

    account.email_verified = True

    account.save()

    rec = models.Recruiter()
    rec.account = account
    rec.key = dataplus.getUniqueId()

    rec.email = email
    rec.name = name
    rec.organization = organization
    rec.telephone = ""

    # default values
    rec.verified = True  # only through invites
    rec.verified_on = datetime.datetime(1981, 1, 9)  # default date min value ;)
    rec.results_last_sent_on = datetime.datetime(1981, 1, 9)  # Jes' bday -- default min date

    rec.save()

    models.RecruiterData(recruiter=rec).save()

    models.Token.getNew(email, type="RecPropaganda")

    return rec
コード例 #2
0
def addRecruiter(email, name, organization):

    print('creating Recruiter ' + email + ' ' + name + ' ' + organization)

    account = models.Account()
    account.username = email
    account.password = dataplus.hash(dataplus.getUniqueId())
    account.account_type = 'FR'
    account.account_state = 'I'
    
    account.email_verified = True
        
    account.save()

    rec = models.Recruiter()
    rec.account = account
    rec.key = dataplus.getUniqueId()

    rec.email = email
    rec.name = name
    rec.organization = organization
    rec.telephone = ''

    #default values
    rec.verified = True #only through invites
    rec.verified_on = datetime.datetime(1981, 1, 9) #default date min value ;)
    rec.results_last_sent_on = datetime.datetime(1981, 1, 9)   #Jes' bday -- default min date

    rec.save()
    
    models.RecruiterData(recruiter=rec).save()
    
    models.Token.getNew(email, type='RecPropaganda')

    return rec
コード例 #3
0
ファイル: user.py プロジェクト: panyang/JobHunt
def addFreeUser(doc_filename, doc_filepath):
    user_key = dataplus.getUniqueId()
    user = models.User.create(user_key,
                              dataplus.getUniqueId(),
                              'FU',
                              user_key,
                              doc_filename=doc_filename,
                              doc_filepath=doc_filepath,
                              resume_updated_on=datetime.datetime.utcnow())
    return user
コード例 #4
0
ファイル: recruiters_signup.py プロジェクト: jeswin/JobHunt
def addRecruiter(email, password, name, organization, telephone, token, through_invite):
    account = models.Account()
    account.username = email
    account.password = dataplus.hash(password)
    account.account_type = 'FR'
    account.account_state = 'A'
    
    account.email_verified = False
    if through_invite:
        account.email_verified = True
        
    account.save()

    rec = models.Recruiter()
    rec.account = account
    rec.key = dataplus.getUniqueId()

    rec.email = email
    rec.name = name
    rec.organization = organization
    rec.telephone = telephone

    #default values
    rec.verified = True #only through invites
    rec.verified_on = datetime.datetime(1981, 1, 9) #default date min value ;)
    rec.results_last_sent_on = datetime.datetime(1981, 1, 9)   #Jes' bday -- default min date

    rec.save()
    
    models.RecruiterData(recruiter=rec).save()
    
    #delete the token
    token.delete()

    return rec
コード例 #5
0
ファイル: user.py プロジェクト: jeswin/JobHunt
def addPremiumUser(name, email, password, telephone):
    user_key = dataplus.getUniqueId()
    proxy_email = generateAnonMailId()
    user = models.User.create(email, password, 'PU', user_key, name, email, telephone, proxy_email=proxy_email)
    user.account.account_state = 'I'
    user.account.save()
    
    return user
コード例 #6
0
ファイル: token.py プロジェクト: jeswin/JobHunt
 def getNew(cls, owner, tag='', type='ForgotPassword'):
     token = Token()
     token.value = dataplus.getUniqueId()
     token.owner = owner
     token.tag = tag
     token.type = type
     
     token.save()
     return token.value
コード例 #7
0
ファイル: user.py プロジェクト: panyang/JobHunt
def addPremiumUser(name, email, password, telephone):
    user_key = dataplus.getUniqueId()
    proxy_email = generateAnonMailId()
    user = models.User.create(email,
                              password,
                              'PU',
                              user_key,
                              name,
                              email,
                              telephone,
                              proxy_email=proxy_email)
    user.account.account_state = 'I'
    user.account.save()

    return user
コード例 #8
0
def addRecruiter(email, password, name, organization, telephone, token,
                 through_invite):
    account = models.Account()
    account.username = email
    account.password = dataplus.hash(password)
    account.account_type = 'FR'
    account.account_state = 'A'

    account.email_verified = False
    if through_invite:
        account.email_verified = True

    account.save()

    rec = models.Recruiter()
    rec.account = account
    rec.key = dataplus.getUniqueId()

    rec.email = email
    rec.name = name
    rec.organization = organization
    rec.telephone = telephone

    #default values
    rec.verified = True  #only through invites
    rec.verified_on = datetime.datetime(1981, 1, 9)  #default date min value ;)
    rec.results_last_sent_on = datetime.datetime(
        1981, 1, 9)  #Jes' bday -- default min date

    rec.save()

    models.RecruiterData(recruiter=rec).save()

    #delete the token
    token.delete()

    return rec
コード例 #9
0
ファイル: mail_pickup_job.py プロジェクト: panyang/JobHunt
def saveEmailedResumes():
    global error_count
    pop = poplib.POP3(pop_server)
    pop.user(pop_user)
    pop.pass_(pop_pass)
    stats = pop.stat()
    rx_headers = re.compile('^(From|To|Subject|Content-Type):', re.IGNORECASE)

    if stats and stats[0] > 0:
        connection = psycopg2.connect(
            "dbname='jhindb' user='******' password='******' host='127.0.0.1'"
        )
        cursor = connection.cursor()

        time_now = datetime.datetime.utcnow()
        count = stats[0]
        for i in range(1, 1 + count):
            try:
                resp, lines, bytes = pop.top(i, 10)
                req_lines = filter(rx_headers.match, lines)
                headers = map(lambda x: x.split(': ', 1), req_lines)

                def find_in_headers(hdr_name):
                    res = filter(lambda x: x[0].lower() == hdr_name.lower(),
                                 headers)
                    if len(res) > 0: return res[0][1]
                    else: return ''

                doc_filename = None
                doc_filepath = None
                has_doc = False
                if find_in_headers('Content-Type').lower().startswith(
                        'multipart'):

                    msg = email.message_from_string('\n'.join(pop.retr(i)[1]))
                    body = {'html': '', 'plain': ''}
                    for part in msg.walk():
                        if part.get_content_maintype() == 'text':
                            sub_type = part.get_content_subtype()
                            if sub_type in ['plain', 'html']:
                                data = dataplus.decode(
                                    part.get_payload(decode=True))
                                if len(data) < 25: pass
                                body[sub_type] = data

                        if part.get_content_maintype(
                        ) == 'application' and part.get_content_subtype(
                        ) == 'msword':
                            doc_filepath = saveResumeFile(
                                part.get_payload(decode=True))
                            doc_filename = part.get_filename()
                            has_doc = True

                    if doc_filename:
                        stmt = "INSERT INTO website_receivedmail (from_address, subject, body_html, body_text, doc_filepath, received_on)"
                        stmt += " VALUES (%(from_address)s, %(subject)s, %(html_body)s, %(plain_body)s, %(doc_filepath)s, %(time_now)s)"
                        cursor.execute(
                            stmt, {
                                'from_address': find_in_headers('From')[:100],
                                'subject': find_in_headers('Subject')[:100],
                                'html_body': body['html'],
                                'plain_body': body['plain'],
                                'doc_filepath': doc_filepath,
                                'time_now': str(time_now)
                            })
                        cursor.execute(
                            "SELECT CURRVAL('website_receivedmail_id_seq');")
                        mail_id = str(cursor.fetchone()[0])
                        resume_key = dataplus.getUniqueId()

                        stmt = 'INSERT INTO website_resume (doc_filename, doc_filepath, html_filepath, text_filepath, doc_hash, posted_on, mail_ref_id, "name", email, experience, tags, industry, "location", current_employer, summary, "key", tagged, is_active, min_salary, desired_employer) '
                        stmt += "VALUES (%(doc_filename)s ,%(doc_filepath)s, '', '', '', %(time_now)s, %(mail_id)s, '', '', 0, '', '', '', '', '', %(resume_key)s, False, False, 0, '')"
                        cursor.execute(
                            stmt, {
                                'doc_filename': doc_filename,
                                'doc_filepath': doc_filepath,
                                'time_now': str(time_now),
                                'mail_id': mail_id,
                                'resume_key': resume_key
                            })

                from_hdr = find_in_headers('From')
                candidate_name = getNameFromHeader(from_hdr)
                if has_doc:
                    params = {'name': candidate_name, 'resume_key': resume_key}
                    mailer.sendResumeReceivedMail(from_hdr, params)
                    eventnotifier.sendEventNotification(
                        'New Resume by mail: %s posted on: %s' %
                        (doc_filename,
                         time_now.strftime('%d/%m/%Y %H:%M:%S %p')))
                else:
                    params = {'name': candidate_name}
                    mailer.sendInvalidResumeMail(from_hdr, params)

                pop.dele(i)

            except:
                error_count += 1
                setErrorCount(error_count)
                logError('Processing mail ' + find_in_headers('From') + ' - ' +
                         find_in_headers('Subject') + ' failed : ' +
                         str(sys.exc_info()[0]) + ', ' +
                         str(sys.exc_info()[1]))
                if error_count == max_errors:
                    logError(
                        'Jobhunt Job Error: Stopping mail_pickup_job as it has encountered Maximum number of errors.'
                    )
                    break

        connection.commit()
    pop.quit()
コード例 #10
0
ファイル: mail_pickup_job.py プロジェクト: panyang/JobHunt
def getNewFilepath():
    target_dir = doc_save_dir + '/' + time.strftime("%d%m%Y", time.gmtime())
    if not os.path.exists(target_dir): os.mkdir(target_dir)
    return target_dir + '/' + dataplus.getUniqueId() + '.doc'
コード例 #11
0
ファイル: mail_pickup_job.py プロジェクト: jeswin/JobHunt
def getNewFilepath():
    target_dir = doc_save_dir + '/' + time.strftime("%d%m%Y", time.gmtime())
    if not os.path.exists(target_dir):  os.mkdir(target_dir)
    return target_dir + '/' + dataplus.getUniqueId() + '.doc'
コード例 #12
0
ファイル: mail_pickup_job.py プロジェクト: jeswin/JobHunt
def saveEmailedResumes():
    global error_count
    pop = poplib.POP3(pop_server)
    pop.user(pop_user)
    pop.pass_(pop_pass)
    stats = pop.stat()
    rx_headers = re.compile('^(From|To|Subject|Content-Type):',re.IGNORECASE)
    
    if stats and stats[0] > 0:  
        connection = psycopg2.connect("dbname='jhindb' user='******' password='******' host='127.0.0.1'")
        cursor = connection.cursor()
        
        time_now = datetime.datetime.utcnow()
        count = stats[0]
        for i in range(1,1+count):
            try:
                resp, lines, bytes = pop.top(i,10)
                req_lines = filter(rx_headers.match, lines)
                headers = map(lambda x: x.split(': ', 1), req_lines)
                
                def find_in_headers(hdr_name):
                    res = filter(lambda x: x[0].lower() == hdr_name.lower(), headers)
                    if len(res) > 0:    return res[0][1]
                    else:   return ''
                
                doc_filename = None
                doc_filepath = None
                has_doc = False
                if find_in_headers('Content-Type').lower().startswith('multipart'):
                
                    msg = email.message_from_string('\n'.join(pop.retr(i)[1]))
                    body = {'html':'', 'plain':''}
                    for part in msg.walk():
                        if part.get_content_maintype() == 'text':
                            sub_type = part.get_content_subtype()
                            if sub_type in ['plain','html']:
                                data = dataplus.decode(part.get_payload(decode=True))
                                if len(data) < 25:  pass
                                body[sub_type] = data
                        
                        if part.get_content_maintype() == 'application' and part.get_content_subtype() == 'msword':
                            doc_filepath = saveResumeFile(part.get_payload(decode=True))
                            doc_filename = part.get_filename()
                            has_doc = True
                    
                    if doc_filename:
                        stmt = "INSERT INTO website_receivedmail (from_address, subject, body_html, body_text, doc_filepath, received_on)"
                        stmt += " VALUES (%(from_address)s, %(subject)s, %(html_body)s, %(plain_body)s, %(doc_filepath)s, %(time_now)s)"
                        cursor.execute(stmt, {'from_address':find_in_headers('From')[:100], 'subject':find_in_headers('Subject')[:100],
                                            'html_body':body['html'], 'plain_body':body['plain'],
                                            'doc_filepath':doc_filepath, 'time_now':str(time_now)})
                        cursor.execute("SELECT CURRVAL('website_receivedmail_id_seq');")
                        mail_id = str(cursor.fetchone()[0])
                        resume_key = dataplus.getUniqueId()
                        
                        stmt = 'INSERT INTO website_resume (doc_filename, doc_filepath, html_filepath, text_filepath, doc_hash, posted_on, mail_ref_id, "name", email, experience, tags, industry, "location", current_employer, summary, "key", tagged, is_active, min_salary, desired_employer) '
                        stmt += "VALUES (%(doc_filename)s ,%(doc_filepath)s, '', '', '', %(time_now)s, %(mail_id)s, '', '', 0, '', '', '', '', '', %(resume_key)s, False, False, 0, '')"
                        cursor.execute(stmt, {'doc_filename':doc_filename, 'doc_filepath':doc_filepath, 'time_now':str(time_now), 'mail_id':mail_id, 'resume_key':resume_key})
                    
                from_hdr = find_in_headers('From')
                candidate_name = getNameFromHeader(from_hdr)
                if has_doc:
                    params = {'name':candidate_name, 'resume_key': resume_key}
                    mailer.sendResumeReceivedMail(from_hdr, params)
                    eventnotifier.sendEventNotification('New Resume by mail: %s posted on: %s' % (doc_filename, time_now.strftime('%d/%m/%Y %H:%M:%S %p')))
                else:
                    params = {'name': candidate_name}
                    mailer.sendInvalidResumeMail(from_hdr, params)
                
                pop.dele(i)
                    
            except:
                error_count += 1
                setErrorCount(error_count)
                logError('Processing mail ' + find_in_headers('From') + ' - ' + find_in_headers('Subject') + ' failed : ' + str(sys.exc_info()[0]) + ', ' + str(sys.exc_info()[1]))
                if error_count == max_errors:
                    logError('Jobhunt Job Error: Stopping mail_pickup_job as it has encountered Maximum number of errors.')
                    break
                
        connection.commit()
    pop.quit()
コード例 #13
0
ファイル: user.py プロジェクト: jeswin/JobHunt
def addFreeUser(doc_filename, doc_filepath):
    user_key = dataplus.getUniqueId()
    user = models.User.create(user_key, dataplus.getUniqueId(), 'FU', user_key, doc_filename=doc_filename, doc_filepath=doc_filepath, resume_updated_on=datetime.datetime.utcnow())    
    return user