def createRecruiter(username, password, name, email, designation, company=None): if (models.Account.objects.filter(username=username).count() > 0): return None account = models.Account() account.username = username account.password = dataplus.hash(password) account.account_type = 'R' account.account_state = 'A' account.name = name account.email = email account.save() rec = models.Recruiter() rec.account = account rec.username = username rec.name = name rec.email = email rec.designation = designation rec.company = company rec.save() mru_data = models.RecruiterMRUData() mru_data.last_accessed_time = datetime.datetime.utcnow() mru_data.location = 'Bangalore' mru_data.last_used_industry_category = models.IndustryCategory.objects.get(name='Software/IT') #Bad.. Need industry category to be created first mru_data.recruiter = rec mru_data.save() return rec
def validatePassword(account_id, password): try: if account_id > 0: account = models.Account.objects.get(id=account_id) if (account.password == dataplus.hash(password)): return True return False except: return False
def doAjaxLogin(username, password): try: account = models.Account.objects.get(username=username.lower(), password=dataplus.hash(password)) except: return False, None, None, 'Error: Invalid username or password.' session_id = sessions_client.query('addNewSession', [account.username]) if session_id: updateLivewireData(session_id, account) if account.account_type == 'U': if account.account_state == 'A': return True, session_id,'/me/', None elif account.account_state == 'I': return True, session_id,'/me/createresume.htm?action=revisit', None if account.account_type == 'R': return True, session_id,'/recruiters/', None return False, None, None, 'System error - unable to login. We have logged the error, and should be able to resolve it soon.'
def handle(request): if request.method == 'GET': return render_to_response('recruiters/signup.htm') elif request.method == 'POST': result, response = validateRequest(request) if not result: return response existing_users = models.Account.objects.filter(username=dataplus.dictGetVal(request.REQUEST,'username')) if existing_users.count() > 0: return render_to_response('recruiters/signup.htm', {'error_html': '<p class="error-note">Username already exists. Please choose another.</p>'}) else: #add some transactions here. account = models.Account() account.username = dataplus.dictGetVal(request.REQUEST,'username') account.name = dataplus.dictGetVal(request.REQUEST,'name') account.password = dataplus.hash(dataplus.dictGetVal(request.REQUEST,'password1')) account.account_type = 'R' account.account_state = 'A' account.email = dataplus.dictGetVal(request.REQUEST,'email',escapeHtml=True) account.save() rec = models.Recruiter() rec.account = account rec.username = dataplus.dictGetVal(request.REQUEST,'username') rec.name = dataplus.dictGetVal(request.REQUEST,'name') rec.email = dataplus.dictGetVal(request.REQUEST,'email',escapeHtml=True) rec.designation = dataplus.dictGetVal(request.REQUEST,'designation',escapeHtml=True) rec.company = dataplus.dictGetVal(request.REQUEST,'company',escapeHtml=True) rec.company_website = dataplus.dictGetVal(request.REQUEST,'companyWebsite',escapeHtml=True) rec.save() mru_data = models.RecruiterMRUData() mru_data.last_accessed_time = datetime.datetime.utcnow() mru_data.recruiter = rec mru_data.save() new_account = models.Account.objects.get(username=dataplus.dictGetVal(request.REQUEST,'username')) request.session['account_id'] = new_account.id return HttpResponseRedirect('accountcreated.htm')
def handle(request): myself = siteaction.getLoggedInAccount(request) if not myself: return HttpResponseRedirect('/login.htm') #TODO: notify user about success, success_page will change logged_in_type = siteaction.getLoggedInAccountType(request) if logged_in_type == 'U': pwd_page = 'me/changepassword.htm' success_page = '/me/editsettings.htm?flashId=pwd_chnged' elif logged_in_type == 'R': pwd_page = 'recruiters/changepassword.htm' success_page = '/recruiters/' if request.method == 'GET': return siteaction.render_to_response(pwd_page, {'myself':myself}) elif request.method == 'POST': #Password length >= 6 and <=12 valid, invalid_msg = dataplus.isLengthValid(dataplus.dictGetVal(request.REQUEST, 'password1'), 6, 12, 'Password') if not valid: return siteaction.render_to_response(pwd_page, {'error_html': '<p class="error-note">' + invalid_msg + '</p>'}) #Passwords should match if dataplus.dictGetVal(request.REQUEST, 'password1') != dataplus.dictGetVal(request.REQUEST, 'password2'): return siteaction.render_to_response(pwd_page, {'error_html': '<p class="error-note">Passwords do not match.</p>'}) #Is the Old Password Check if (siteaction.validatePassword(myself.id, dataplus.dictGetVal(request.REQUEST, 'oldpassword'))): myself.password = dataplus.hash(dataplus.dictGetVal(request.REQUEST, 'password1')) myself.save() return HttpResponseRedirect(success_page) else: return siteaction.render_to_response(pwd_page, {'error_html': '<p class="error-note">Old password was incorrect. Try again.</p>'})
def handle(request): #TODO: Check 24 hour validity period passkey = dataplus.dictGetVal(request.REQUEST, 'passwordChangeKey', '') change_req = dataplus.returnIfExists(models.PasswordChangeRequest.objects.filter(req_random_key=passkey,created_at__gte=(datetime.datetime.utcnow() - datetime.timedelta(1)))) if not change_req: return siteaction.render_to_response('showmessage.htm', {'msg_heading': 'Password Reset', 'msg_html': 'Invalid link. The password reset link that you clicked is either invalid or expired. ' + \ 'You can try to <a href="forgotpassword.htm">Reset the Password</a> again.'}) if request.method == 'GET': return siteaction.render_to_response('resetpassword.htm', {'passwordChangeKey': dataplus.dictGetVal(request.REQUEST,'passwordChangeKey')}) elif request.method == 'POST': #Password length >= 6 and <=12 valid, invalid_msg = dataplus.isLengthValid(dataplus.dictGetVal(request.REQUEST,'password1'), 6, 12, 'Password') if not valid: return siteaction.render_to_response('resetpassword.htm', {'error_html': '<p class="error-note">' + invalid_msg + '</p>', 'passwordChangeKey': dataplus.dictGetVal(request.REQUEST,'passwordChangeKey')}) #Passwords should match if dataplus.dictGetVal(request.REQUEST,'password1') != dataplus.dictGetVal(request.REQUEST,'password2'): return siteaction.render_to_response('resetpassword.htm', {'error_html': '<p class="error-note">Passwords do not match.</p>', 'passwordChangeKey': dataplus.dictGetVal(request.REQUEST,'passwordChangeKey')}) account = change_req.account account.password = dataplus.hash(dataplus.dictGetVal(request.REQUEST,'password1')) account.save() change_req.delete() return siteaction.render_to_response('showmessage.htm', {'msg_heading': 'Password Reset', 'msg_html': 'Your password was reset. You can now login with your new password. ' + \ '<a href="/login.htm">Login</a>'})
def doLogin(request, referer=None): try: account = models.Account.objects.get(username=dataplus.dictGetVal(request.REQUEST, 'username').lower(), password=dataplus.hash(dataplus.dictGetVal(request.REQUEST, 'password'))) except: return render_to_response('login.htm', {'error_message': '<p style="color:#FF0000">Error: Invalid username or password.</p>'}) session_id = sessions_client.query('addNewSession', [account.username]) if session_id: updateLivewireData(session_id, account) if (not referer) or (referer == ''): if account.account_type == 'U': if account.account_state == 'A': return redirectWithCookie('/me/', 'session_id', session_id) elif account.account_state == 'I': return redirectWithCookie('/me/createresume.htm?action=revisit', 'session_id', session_id) if account.account_type == 'R': return redirectWithCookie('/recruiters/', 'session_id', session_id) else: return redirectWithCookie(referer, 'session_id', session_id) return render_to_response('login.htm', {'error_html': '<p>System error - unable to login. We have logged the error, and should be able to resolve it soon.</p>', 'show_back_btn': True})
def createUser(username, name, password, email, country, industry_category='Software/IT', experience=0, invitation=None): username = username.lower() #add some transactions here? account = models.Account() account.username = username account.name = name account.password = dataplus.hash(password) account.email = email account.account_type = 'U' account.account_state = 'A' account.save() user = models.User() user.account = account user.username = username user.name = name user.email = email user.last_access_time = datetime.datetime.utcnow() user.last_update_time = datetime.datetime.utcnow() user.resume_update_time = config.min_date #some defaults for the images user.image_file_path = config.noimg user.image_size1_file_path = config.noimg_50 user.image_size2_file_path = config.noimg_72 user.image_size3_file_path = config.noimg_128 resume_contents = models.ResumeContents() resume_contents.text = 'Resume not uploaded yet.' resume_contents.masked_text = 'Resume not uploaded yet.' resume_contents.html_style = '' resume_contents.html_formatter = '' resume_contents.save() user.resume_contents = resume_contents #Empty vessels make more noise user.phone = '' user.personal_desc = '' user.small_desc = '' user.blog_url = '' user.hilite = '' user.resume_dir = '' user.salary_range_lower = 0 user.salary_range_upper = 0 user.working_since = datetime.datetime.utcnow() - datetime.timedelta(experience * 365) user.industry_category = models.IndustryCategory.objects.get(name=industry_category) #save maadi! user.save() user_settings = models.UserSettings() user_settings.email_fwd_messages = False user_settings.email_fwd_jobrefs = True user_settings.email_fwd_alerts = True user_settings.phone_num_visibility = 'friends' user_settings.resume_visibility = 'everyone' user_settings.interest_in_new_job = 'active' user_settings.preferred_location = 'Anywhere' user_settings.original_resume_format = '' user_settings.available_resume_download_formats = '' user_settings.preferred_resume_download_format = 'pdf' user_settings.resume_download_format_set = False user_settings.enable_voip_dial = True user_settings.country = country user_settings.currency = statix.country_currency_map[user_settings.country] user_settings.user = user user_settings.save() chat_settings = models.ChatSettings() chat_settings.account = account chat_settings.online_status = 'everyone' chat_settings.custom_message = '' chat_settings.invite_preference = 'friends' chat_settings.ignore_list = '' chat_settings.image_size1_file_path = config.noimg_50 chat_settings.image_size2_file_path = config.noimg_72 chat_settings.image_size3_file_path = config.noimg_128 chat_settings.save() matching_jobs = models.MatchingJobs() matching_jobs.user = user matching_jobs.jobs = '' matching_jobs.save() mru_data = models.UserMRUData() mru_data.last_accessed_time = datetime.datetime.utcnow() mru_data.user = user mru_data.save() mail1_subject = 'Let\'s get started with Socialray' mail1_body_html = '<p>Welcome to Socialray.</p><p>Some of the things you can try out on Socialray:<br />' + \ ' - Making your Resume searchable through Google<br />' + \ ' - <a href="/me/searchpeople.htm">Find friends</a> and other connections<br />' + \ ' - Join <a href="/me/searchcommunities.htm">Interesting Communities</a><br />' + \ ' - Add credibility to your resume with <a href="/profiles/' + user.username + '/">Testimonials</a><br />' + \ ' - Refer jobs to your Friends and Communities<br />' + \ ' - Chat with your friends using Socialray Web Chat<br />' + \ ' - You can even <a href="/me/editmedia.htm">attach videos</a> to your resume</p>' + \ '<p>Socialray is learning. And we are evolving with new features. So keep checking.</p>' + \ '<p>Regards,<br />Socialray Team</p>' mail1_body_text = 'Welcome to Socialray. \r\n\r\n Some of the things you can try out on Socialray:\r\n' + \ ' - Making your Resume searchable through Google\r\n' + \ ' - Find friends and other connections\r\n' + \ ' - Join Interesting Communities\r\n' + \ ' - Add credibility to your resume with Testimonials\r\n' + \ ' - Refer jobs to your Friends and Communities\r\n' + \ ' - Chat with your friends using Socialray Web Chat\r\n' + \ ' - You can even attach videos to your resume\r\n\r\n' + \ 'Socialray is learning. And we are evolving with new features. So keep checking.\r\n\r\n' + \ 'Regards,\r\nSocialray Team\r\n\r\n' mail1_body_html_external = '<p>Welcome to Socialray.</p><p>Some of the things you can try out on Socialray:<br />' + \ ' - Making your Resume searchable through Google<br />' + \ ' - <a href="http://www.socialray.org/me/searchpeople.htm">Find friends</a> and other connections<br />' + \ ' - Join <a href="http://www.socialray.org/me/searchcommunities.htm">Interesting Communities</a><br />' + \ ' - Add credibility to your resume with <a href="http://www.socialray.org/profiles/' + user.username + '/">Testimonials</a><br />' + \ ' - Refer Jobs to your Friends and Communities<br />' + \ ' - Chat with your friends using Socialray Web Chat<br />' + \ ' - You can even <a href="http://www.socialray.org/me/editmedia.htm">Attach Videos</a> to your resume</p>' + \ '<p>Socialray is learning. And we are evolving with new features. So keep checking.</p>' + \ '<p>Regards,<br />Socialray Team</p>' mailman.sendToInbox(None, user.username, mail1_subject, mail1_body_html, 'SA') mailman.sendOneWayMail('Socialray ' + config.system_email, ['"' + user.name + '" <' + user.email + '>'], mail1_subject, mail1_body_html_external, None, None, mail1_body_text) mail2_subject = 'Take a tour' mail2_body_html = '<p>Socialray has added some really exciting features, like the new chat system, yahoo and skype integration and better communities.</p>' + \ '<p>We have created the <a href="/tour.html">socialray tour</a>, to show you all that.</p>' + \ '<p>Regards,<br />Socialray Team</p>' mail2_body_text = 'Socialray has added some really exciting features, like the new chat system, yahoo and skype integration and better communities.\r\n\r\n' + \ 'We have created the socialray tour at http://www.socialray.org/tour.html, to show you all that.\r\n\r\n' + \ 'Regards,\r\nSocialray Team\r\n\r\n' mailman.sendToInbox(None, user.username, mail2_subject, mail2_body_html, 'SA') mailman.sendOneWayMail('Socialray ' + config.system_email, ['"' + user.name + '" <' + user.email + '>'], mail2_subject, mail2_body_html, None, None, mail2_body_text) if invitation: post_signup_actions = models.PostSignupActions(user=user) post_signup_actions.actions = invitation post_signup_actions.save() return user
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