def mailUsers(): #get the data from PostgreSql stmt = """SELECT R.id, key, name, organization, email, T.value AS token_value FROM website_recruiter AS R INNER JOIN website_token AS T ON T.owner = R.email INNER JOIN website_account AS A ON R.account_id = A.id WHERE A.account_state = 'I' AND A.email_verified = TRUE""" cursor.execute(stmt) results = cursor.fetchall() min_datetime = datetime.datetime(1980, 10, 3) #min_date mailing_list = getMailingList() for row in results: rec = RecInfo(row) for (subject, usr_list) in mailing_list: print( 'sending email to ' + rec.email + 'invite link http://jobhunt.in/recruiters/dashboard.htm?rec_token=' + rec.token_value) mailer.sendAdminRecruiterInvites( rec.email, { 'token': rec.token_value, 'key': rec.key, 'matching_users': usr_list, 'header': subject }, subject) for usr in usr_list: notifications.addNotification(usr['id'], 'ProfEmailed', data={ 'recruiter_id': rec.id, 'recruiter_email': rec.email }) notifications.addNotification( rec.email, 'PropResults', ','.join([str(usr['id']) for usr in usr_list]))
def handle(request): if not request.user.is_authenticated(): return HttpResponseRedirect('/admin/') if request.method == 'GET': return codejar.actions.render(request, 'sys/recinvite.htm') elif request.method == 'POST': rec_emails = dataplus.dictGetSafeVal(request.REQUEST, 'emails', '') keywords = dataplus.dictGetSafeVal(request.REQUEST, 'keywords', '') experience = dataplus.dictGetVal(request.REQUEST, 'experience', 0, string.atoi) location = dataplus.dictGetSafeVal(request.REQUEST, 'location', '') key = dataplus.dictGetSafeVal(request.REQUEST, 'key', '') if rec_emails: min_datetime = datetime.datetime(1980, 10, 3) #min_date response = search_helper.matchResumes(keywords, experience, location, 99999999, min_datetime) usr_list = response.results usr_list.sort(lambda x,y: x['rating']-y['rating']) usr_list = addFormatting(usr_list[:50]) for email in rec_emails.split(','): token_value = models.Token.getNew('system', email, 'Invites') sel_users = getRandomUsers(usr_list) for usr in sel_users: notifications.addNotification(usr['id'], 'ProfEmailed', data={'recruiter_email':email}) mailer.sendAdminRecruiterInvites(email, {'token':token_value, 'key':key, 'matching_users':sel_users}) return HttpResponseRedirect('/sys/recinvite.htm?flashId=recruiters_invited')
def mailUsers(): #get the data from PostgreSql stmt = """SELECT R.id, key, name, organization, email, T.value AS token_value FROM website_recruiter AS R INNER JOIN website_token AS T ON T.owner = R.email INNER JOIN website_account AS A ON R.account_id = A.id WHERE A.account_state = 'I' AND A.email_verified = TRUE""" cursor.execute(stmt) results = cursor.fetchall() min_datetime = datetime.datetime(1980, 10, 3) #min_date mailing_list = getMailingList() for row in results: rec = RecInfo(row) for (subject, usr_list) in mailing_list: print('sending email to ' + rec.email + 'invite link http://jobhunt.in/recruiters/dashboard.htm?rec_token=' + rec.token_value) mailer.sendAdminRecruiterInvites(rec.email, {'token':rec.token_value, 'key':rec.key, 'matching_users':usr_list, 'header':subject}, subject) for usr in usr_list: notifications.addNotification(usr['id'], 'ProfEmailed', data={'recruiter_id':rec.id, 'recruiter_email':rec.email}) notifications.addNotification(rec.email, 'PropResults', ','.join([str(usr['id']) for usr in usr_list]))