def inviteToChatByEmail(request, session_id): try: chat_id = dataplus.dictGetVal(request.REQUEST, 'chatId', '') if not chat_id: return ajaxian.getFailureResp('error:invalid_chatId') username = dataplus.dictGetVal(request.REQUEST, 'username', '') name = dataplus.dictGetVal(request.REQUEST, 'name', '') invited_name = dataplus.dictGetVal(request.REQUEST, 'invitedName', '', lambda x: x.strip()) invited_email = dataplus.dictGetVal(request.REQUEST, 'invitedEmail', '', lambda x: x.strip()) text = dataplus.dictGetSafeVal(request.REQUEST, 'text', '') subject = 'Chat Invitation to Socialray' sender = name + '<' + username + '*****@*****.**>' html_message = '<p>Hello ' + invited_name + '</p><p>' + name + ' wants to have a chat with you and has sent you the following message ' + \ 'inviting you to a chat session in Socialray.</p><p>"' + text + '"</p>' + \ '<p>You can <a href="' + config.server_base_url + '/chat/startchat.htm?chatId=' + chat_id + '">join ' + name + '</a> in chat now.</p>' + \ '<p>Regards,<br />from Socialray</p>' text_message = 'Hello ' + invited_name + '\r\n' + name + ' wants to have a chat with you and has sent you the following message ' + \ 'inviting you to a chat session in Socialray.\r\n"' + text + '"\r\n' + \ 'Please visit ' + config.server_base_url + '/chat/startchat.htm?chatId=' + chat_id + ' to join ' + name + ' in chat now.\r\n' + \ 'regards,\r\nfrom Socialray\r\n\r\n' mailman.sendOneWayMail(sender, [invited_name + '<' + invited_email + '>'], subject, html_message, None, None, text_message) livewire_client.command('inviteByEmail', [session_id, chat_id, invited_name, invited_email]) return ajaxian.getSuccessResp('') except: return ajaxian.getFailureResp('error:unknown')
def handle(request): logged_in_type = siteaction.getLoggedInAccountType(request) if logged_in_type == 'U': myself = siteaction.getLoggedInUser(request) html_file = 'me/sentitems.htm' elif logged_in_type == 'R': myself = siteaction.getLoggedInRecruiter(request) html_file = 'recruiters/sentitems.htm' else: return HttpResponseRedirect('/login.htm') if request.method == 'POST': if dataplus.dictGetVal(request.REQUEST, 'action', '') == 'delete': deleteMessages(request, myself) return HttpResponseRedirect('/mailbox/sentitems.htm?flashId=msg_del'); 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(html_file, { 'message_box_html': getMessageBoxHtml(request, myself), 'action_result':action_result, 'myself': myself })
def handle(request): myself = siteaction.getLoggedInUser(request) if not myself: return HttpResponseRedirect('/login.htm') if request.method == 'GET': action_result = '' if dataplus.dictGetVal(request.REQUEST, 'flashId'): action_result = dataplus.dictGetVal(statix.action_messages, dataplus.dictGetVal(request.REQUEST, 'flashId'), '') myself.image_url = dataplus.getStaticUrl(myself.image_size3_file_path) return siteaction.render_to_response('me/changephoto.htm', { 'action_result':action_result, 'myself':myself}) elif request.method == 'POST': success, error_code, img1, img2, img3, img4 = studio.saveImage_x4_ByDate(request, 'user_' + myself.username, 'photograph') if success: if myself.image_file_path != img1: iolib.deleteFiles([myself.image_file_path, myself.image_size1_file_path, \ myself.image_size2_file_path, myself.image_size3_file_path]) myself.image_file_path = img1 myself.image_size1_file_path = img2 myself.image_size2_file_path = img3 myself.image_size3_file_path = img4 myself.save() chat_settings = models.ChatSettings.objects.get(account=myself.account) chat_settings.image_size1_file_path = img2 chat_settings.image_size2_file_path = img3 chat_settings.image_size3_file_path = img4 chat_settings.save() session_id = request.COOKIES['session_id'] siteaction.updateLivewireData(session_id, myself.account) else: return HttpResponseRedirect('/me/changephoto.htm?flashId=' + error_code) return HttpResponseRedirect('/me/?flashId=usrpic_chnged')
def handle(request): last_id = dataplus.dictGetVal(request.REQUEST, "last_id", 0, string.atoi) first_id = dataplus.dictGetVal(request.REQUEST, "first_id", 0, string.atoi) has_prev_page = False has_next_page = False if last_id: has_prev_page = True communities, has_next_page = getCommunities("next", last_id) elif first_id: has_next_page = True communities, has_prev_page = getCommunities("prev", first_id) else: communities, has_next_page = getCommunities() prev_btn = "" next_btn = "" if communities: total_communities = models.Community.objects.count() if has_prev_page: prev_btn = '<a href="communitylist.htm?first_id=' + str(communities[0].id) + '">PREV</a>' if has_next_page: next_btn = '<a href="communitylist.htm?last_id=' + str(communities[len(communities) - 1].id) + '">NEXT</a>' buttons = prev_btn + " " + next_btn return siteaction.render_to_response( "communitylist.htm", {"communities": communities, "showing_howmany": "", "buttons": buttons} # showing_howmany, )
def handle(request): logged_in_type = siteaction.getLoggedInAccountType(request) if logged_in_type == 'U': myself = siteaction.getLoggedInUser(request) mru_data = models.UserMRUData.objects.get(user__id=myself.id) html_file = 'me/inbox.htm' elif logged_in_type == 'R': myself = siteaction.getLoggedInRecruiter(request) mru_data = models.RecruiterMRUData.objects.get(recruiter__id=myself.id) html_file = 'recruiters/inbox.htm' else: return HttpResponseRedirect('/login.htm') if request.method == 'POST': if dataplus.dictGetVal(request.REQUEST, 'action', '') == 'delete': deleteMessages(request, myself) return HttpResponseRedirect('/mailbox/?flashId=msg_del'); new_msgs_count = models.Message.objects.filter(account__id=myself.account.id, folder='inbox', sent_at__gte=mru_data.last_accessed_time).count() 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(html_file, { 'message_box_html': getMessageBoxHtml(request, myself), 'new_msgs_count': new_msgs_count, 'action_result':action_result, 'myself': myself })
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': resume_visibility = hotmetal.elemSelect([('Everyone', 'everyone'), ('Friends only', 'friends'), ('Nobody', 'nobody')], [], None, None, settings.resume_visibility, 'name="resume_visibility" id="resume_visibility" style="width:120px"') hide_phone_numbers_checked = ('', 'checked="checked"')[settings.phone_num_visibility != 'everyone'] 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/editprivacy.htm', {'resume_visibility':resume_visibility, 'hide_phone_numbers_checked':hide_phone_numbers_checked, 'action_result':action_result, 'myself': myself }) elif request.method == 'POST': settings.resume_visibility = dataplus.dictGetVal(request.REQUEST,'resume_visibility') settings.phone_num_visibility = dataplus.dictGetVal(request.REQUEST, 'hide_phone_numbers', 'everyone', lambda x:'friends') settings.save() return HttpResponseRedirect('/me/editprivacy.htm?flashId=privacy_saved')
def handle(request, comm_id): myself = siteaction.getLoggedInUser(request) if not myself: return HttpResponseRedirect('/login.htm') community = models.Community.objects.select_related().get(id=comm_id) if myself.username != community.owner_username: return siteaction.render_to_response('me/showmessage.htm', {'msg_heading':'Error', 'msg_html':'Unauthorized access.'}) if request.method == 'GET': action_result = '' if dataplus.dictGetVal(request.REQUEST, 'flashId'): action_result = dataplus.dictGetVal(statix.action_messages, dataplus.dictGetVal(request.REQUEST, 'flashId'), '') community.image_url = dataplus.getStaticUrl(community.image_size3_file_path) return siteaction.render_to_response('communities/changephoto.htm', \ {'community':community, 'action_result':action_result, 'myself':myself}) elif request.method == 'POST': success, error_code, img1, img2, img3, img4 = studio.saveImage_x4_ByDate(request, 'comm_' + str(community.id), 'commIcon') if success: if community.image_file_path != img1: iolib.deleteFiles([community.image_file_path, community.image_size1_file_path, \ community.image_size2_file_path, community.image_size3_file_path]) community.image_file_path = img1 community.image_size1_file_path = img2 community.image_size2_file_path = img3 community.image_size3_file_path = img4 community.save() else: return HttpResponseRedirect('/communities/' + str(comm_id) + '/changephoto.htm?flashId=' + error_code) return HttpResponseRedirect('./?flashId=commpic_chnged')
def handle(request): last_id = dataplus.dictGetVal(request.REQUEST, 'last_id', 0, string.atoi) first_id = dataplus.dictGetVal(request.REQUEST, 'first_id', 0, string.atoi) has_prev_page = False has_next_page = False if last_id: has_prev_page = True members, has_next_page = getMembers("usr.id < " + str(last_id)) elif first_id: has_next_page = True members, has_prev_page = getMembers("usr.id > " + str(first_id), False) members.reverse() else: members, has_next_page = getMembers() prev_btn = '' next_btn = '' if members: total_members = models.User.objects.count() if has_prev_page: prev_btn = '<a href="memberlist.htm?first_id=' + str(members[0].id) + '">PREV</a>' if has_next_page: next_btn = '<a href="memberlist.htm?last_id=' + str(members[len(members)-1].id) + '">NEXT</a>' buttons = prev_btn + ' ' + next_btn return siteaction.render_to_response('memberlist.htm', { 'members': members, 'showing_howmany': '',#showing_howmany, 'buttons': buttons })
def handle(request): try: logged_in_type = siteaction.getLoggedInAccountType(request) rcvr_usrname = dataplus.dictGetVal(request.REQUEST,'sendTo') if logged_in_type == 'U': myself = siteaction.getLoggedInUser(request) elif logged_in_type == 'R': myself = siteaction.getLoggedInRecruiter(request) else: return ajaxian.getFailureResp('not_logged_in') rcvr_account = models.Account.objects.get(username=dataplus.dictGetVal(request.REQUEST,'sendTo')) text_message = dataplus.dictGetSafeVal(request.REQUEST,'text') html_message = dataplus.replaceHtmlLineBreaks(text_message) subject = dataplus.dictGetSafeVal(request.REQUEST,'subject') def internalSender(rcvr_accounts): mailman.sendMessage(myself.username, [rcvr.username for rcvr in rcvr_accounts], subject, html_message) def externalSender(rcvr_accounts): sender = '"' + myself.name + '" <' + myself.username + '*****@*****.**>' receivers = ['"' + rcvr.name + '" <' + rcvr.email + '>' for rcvr in rcvr_accounts] mailman.sendMail(sender, receivers, subject, html_message, None, None, text_message, reply_to=myself.email) mailman.sendBySettings([rcvr_account], internalSender, externalSender, 'TextMessage') return ajaxian.getSuccessResp('') except: return ajaxian.getFailureResp('unknown')
def handle(request): if request.method == 'GET': return siteaction.render_to_response('idxcaptcha.htm') elif request.method == 'POST': captchatextin = request.session['signup_captcha_text'] if dataplus.dictGetVal(request.REQUEST,'captcha_text') != captchatextin: return siteaction.render_to_response('idxcaptcha.htm', {'error_html':'The captcha text entered is incorrect.'}) params = request.session['signup-params'] if params['username'].lower() in config.reserved_words or models.Account.objects.filter(username=params['username']).count() > 0: countries = models.Country.objects.all().order_by('name') country_select_html = hotmetal.elemSelect([('Select', '')], countries, lambda x:x.name, lambda x:x.code, dataplus.dictGetVal(request.REQUEST,'country'), 'name="country" id="country" style="width:160px"') industry_cats = models.IndustryCategory.objects.all() industry_cats_html = hotmetal.elemSelect([('Select', '')], industry_cats, lambda x:x.name, lambda x:x.name, dataplus.dictGetVal(request.REQUEST,'industry_category'), 'name="industry_category" id="industry_category" style="width:160px"') experience_select_html = hotmetal.elemSelect([('Select', '-1')], range(0,51), lambda x:x, lambda x:x, dataplus.dictGetVal(request.REQUEST,'experience'), 'name="experience" id="experience" style="width:90px"') error_message = 'Username already exists. Please choose another' return siteaction.render_to_response('index.htm', {'error_html': '<p class="error-note">' + error_message + '</p>', 'name':params['name'], 'username':params['username'], 'email':params['email'], 'country_select_html':country_select_html, 'industry_categories_html':industry_cats_html, 'experience_select_html':experience_select_html}) else: req_username = params['username'].lower() user = siteaction.createUser(req_username, params['name'], params['password'], params['email'], params['country'], params['industry_category'].replace('&','&'), params['experience']) request.session['signup-params'] = None useraccount = user.account #none if these users would have posted their resume, or setup preferences.... todoResumeMail_subject = '<span style="color:#FF9900">Next step: Update your Resume</span>' todoResumeMail_body_html = '<p>To effectively use socialray for Professional Networking and Jobs, you need to update your resume. You can do so by opening the <a href="http://www.socialray.org/me/editresume.htm">Resume Editor</a>.</p>' + \ '<p>Regards,<br />Socialray Team</p>' mailman.sendToInbox(None, req_username, todoResumeMail_subject, todoResumeMail_body_html, 'SA') session_id = sessions_client.query('addNewSession', [useraccount.username]) 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.getStaticUrl(chat_settings.image_size1_file_path), dataplus.getStaticUrl(chat_settings.image_size2_file_path), dataplus.getStaticUrl(chat_settings.image_size3_file_path)]) return siteaction.redirectWithCookie('/me', 'session_id', session_id) else: return HttpResponseRedirect('500.html')
def handle(request): myself = siteaction.getLoggedInUser(request) if not myself: return HttpResponseRedirect('/login.htm') username = dataplus.dictGetVal(request.REQUEST, 'user') if username and username != myself.username: user = dataplus.returnIfExists(models.User.objects.filter(username=username)) if not user: return siteaction.render_to_response('me/showmessage.htm', {'myself':myself, 'msg_heading':'Error', 'msg_html':'Invalid Request'}) heading = user.name + '\'s Friends' else: user = myself heading = '' page = dataplus.dictGetVal(request.REQUEST, 'page', 0, string.atoi) start_friend_num = page * config.friends_per_page last_friend_num = start_friend_num + config.friends_per_page total_friends = user.friends.count() friends = user.friends.all().order_by('-last_access_time')[start_friend_num:last_friend_num] html = '' if user == myself: friends_usernames = [user.username for user in friends] online_status = chat.getOnlineStatus(request, friends_usernames, 'friend') for friend in friends: html += codejar_network.getDescriptiveThumb(friend, True, online_status[friend.username]) else: for friend in friends: html += codejar_network.getDescriptiveThumb(friend) if total_friends == 0: showing_howmany = '0 of 0 friends' else: showing_howmany = str(page*config.friends_per_page + 1) + '-' + str(page*config.friends_per_page + friends.count()) + ' of ' + str(total_friends) prev_btn = '' next_btn = '' page_url = 'friends.htm?' if username: page_url = 'friends.htm?user='******'&' if page != 0: prev_btn = '<input class="medium-btn" type="button" name="prev-button" value="PREV" onclick="javascript:window.location.href=\'' + page_url + 'page=' + str(page-1) + '\'" />' if last_friend_num < total_friends: next_btn = '<input class="medium-btn" type="button" name="next-button" value="NEXT" onclick="javascript:window.location.href=\'' + page_url + 'page=' + str(page+1) + '\'" />' buttons = prev_btn + next_btn return siteaction.render_to_response('me/friends.htm', { 'friends_html': html, 'showing_howmany': showing_howmany, 'heading': heading, 'buttons': buttons, 'myself' : myself })
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')
def handle(request): if request.method == 'GET': if (dataplus.dictGetVal(request.REQUEST, 'action') == 'logout'): siteaction.doLogout(request) return siteaction.render_to_response('alt-index.htm') elif request.method == 'POST': return { 'login':siteaction.doLogin }[dataplus.dictGetVal(request.REQUEST,'action')](request)
def handle(request): myself = siteaction.getLoggedInUser(request) if not myself: return HttpResponseRedirect('/login.htm') if request.method == 'GET': return siteaction.render_to_response('me/searchcommunities.htm', {'showing_search_results': False, 'myself': myself, 'interesting': searchcomm.getInterestingComms(myself)}) elif request.method == 'POST': keywords = dataplus.dictGetVal(request.REQUEST,'keywords') if dataplus.dictGetVal(request.REQUEST,'action') == 'display': page = dataplus.dictGetVal(request.REQUEST,'page',0,string.atoi) pickled_match_list = dataplus.dictGetVal(request.REQUEST,'matches') match_list = cPickle.loads(str(pickled_match_list)) else: keywords = keywords.strip() if keywords != '': match_list = searchcomm.getMatches(keywords) pickled_match_list = cPickle.dumps(match_list) page = 0 else: return siteaction.render_to_response('me/searchcommunities.htm', {'showing_search_results': True, 'myself': myself, 'message':'Please enter a valid search query.'}) start_num = page * config.community_matches_per_page end_num = ((page + 1) * config.community_matches_per_page) display_list = match_list[start_num:end_num] comms_bulk_dict = models.Community.objects.in_bulk(display_list) num_pages = ((len(match_list)-1)/config.community_matches_per_page) + 1 matching_communities = dataplus.getOrderedList(comms_bulk_dict, display_list) for comm in matching_communities: comm.image_url = dataplus.getStaticUrl(comm.image_size2_file_path) if match_list: message = 'Showing ' + str(start_num + 1) + ' - ' + str(start_num + len(matching_communities)) + ' of ' + str(len(match_list)) + ' matches.' else: message = 'Your search did not return any results.' return siteaction.render_to_response('me/searchcommunities.htm', { 'matching_communities': matching_communities, 'matches': cgi.escape(pickled_match_list), 'message': message, 'page_links_html': getPageLinksHtml(num_pages, page), 'keywords': cgi.escape(keywords, True), 'myself': myself, 'showing_search_results': True})
def extractQueryFromRequest(rec, request): post_field = dataplus.dictGetVal(request.REQUEST, 'post_field', '') query = models.RecruiterRecentSearchQuery(recruiter=rec.account) if post_field != '': pickled_query = dataplus.dictGetVal(request.REQUEST,post_field) query_dic = cPickle.loads(pickled_query) if query_dic['industry_category'] != '': query.industry_category = models.IndustryCategory.objects.get(name=query_dic['industry_category']) query.designation = query_dic['designation'] query.mandatory_skills = query_dic['mandatory_skills'] query.desired_skills = query_dic['desired_skills'] query.location = query_dic['location'] query.min_exp_years = query_dic['min_exp_years'] query.max_exp_years = query_dic['max_exp_years'] query.qualifications = query_dic['educational_qualifications'] else: if dataplus.dictGetVal(request.REQUEST, 'industry_category', '') != '': query.industry_category = models.IndustryCategory.objects.get(name=request.REQUEST['industry_category']) query.designation = dataplus.dictGetVal(request.REQUEST, 'designation', escapeHtml=True) query.mandatory_skills = dataplus.dictGetVal(request.REQUEST, 'mandatory_skills', escapeHtml=True) query.desired_skills = dataplus.dictGetVal(request.REQUEST, 'desired_skills', escapeHtml=True) query.location = dataplus.dictGetVal(request.REQUEST, 'location', escapeHtml=True) exp = string.split(request.REQUEST['experience'],'-') query.min_exp_years = string.atoi(exp[0]) query.max_exp_years = string.atoi(exp[1]) query.educational_qualifications = dataplus.dictGetVal(request.REQUEST, 'educational_qualifications', escapeHtml=True) return query
def handle(request): q_id = dataplus.dictGetVal(request.REQUEST, 'qid', '0', string.atoi) if q_id == 0: return HttpResponseRedirect('/login.htm') question = get_object_or_404(models.ResumeQuestion, id=q_id) myself = siteaction.getLoggedInUser(request) if not myself or myself.id != question.receiver.id: return HttpResponseRedirect('/login.htm?' + urllib.urlencode( {'returnUrl':'/me/answerresumequestion.htm?qid=' + str(q_id)})) if question.receiver.id != myself.id: return siteaction.render_to_response('me/showmessage.htm', {'myself':myself, 'msg_heading': 'Error', 'msg_html': 'Access Denied.'}) if request.method == 'GET': return siteaction.render_to_response('me/answerresumequestion.htm', {'myself':myself, 'question':question, 'is_public_checked':dataplus.conditionalValue(lambda: question.is_public == True, 'checked="checked"', '')}) elif request.method == 'POST': question.answer = dataplus.dictGetSafeVal(request.REQUEST, 'answer') question.is_public = dataplus.dictGetVal(request.REQUEST, 'is_public') question.is_answered = True question.save() html_message = myself.name + ' has answered your question (' + question.question + ').<br />' + \ '<strong>Answer: </strong> ' + question.answer text_message = myself.name + ' has answered your question (' + question.question + ').\r\n' + \ 'Answer: ' + question.answer subject = myself.name + ' has answered your question' def internalSender(rcvr_accounts): rcvr = rcvr_accounts[0] mailman.sendToInbox(myself.username, rcvr.username, subject, html_message, 'TM', 'H') def externalSender(rcvr_accounts): sender = '"' + myself.name + '" <' + myself.username + '*****@*****.**>' receivers = ['"' + rcvr.name + '" <' + rcvr.email + '>' for rcvr in rcvr_accounts] mailman.sendMail(sender, receivers, subject, html_message, None, None, text_message, reply_to=myself.email) mailman.sendBySettings([question.sender], internalSender, externalSender, 'AnswerToResumeQuestion') return HttpResponseRedirect('/me/?flashId=rqa_saved')
def handle(request): if request.method == 'GET': socialray_invite = dataplus.dictGetSafeVal(request.REQUEST,'inviteId','') comm_invite = dataplus.dictGetSafeVal(request.REQUEST,'commInviteId','') comm_friend_invite = dataplus.dictGetSafeVal(request.REQUEST,'commFriendInviteId','') invitation = '' if socialray_invite: invitation = 'inviteId=' + socialray_invite elif comm_invite: invitation = 'commInviteId=' + comm_invite elif comm_friend_invite: invitation = 'commFriendInviteId=' + comm_friend_invite countries = models.Country.objects.all().order_by('name') country_select_html = hotmetal.elemSelect([('Select', '')], countries, lambda x:x.name, lambda x:x.code, '', 'name="country" id="country" style="width:160px"') return siteaction.render_to_response('me/signup.htm', {'invitation':invitation, 'cid':dataplus.getUniqueId(), 'country_select_html':country_select_html}) elif request.method == 'POST': result, response = validateRequest(request) if not result: return response username = dataplus.dictGetVal(request.REQUEST, 'username') if username.lower() in config.reserved_words or models.Account.objects.filter(username=username).count() > 0: return siteaction.render_to_response('me/signup.htm', {'error_html': '<p class="error-note">Username already exists. Please choose another.</p>', 'name':dataplus.dictGetVal(request.REQUEST, 'name'), 'username':dataplus.dictGetVal(request.REQUEST, 'username'), 'email':dataplus.dictGetVal(request.REQUEST, 'email'), 'cid':dataplus.getUniqueId()}) else: username = dataplus.dictGetVal(request.REQUEST,'username').lower() siteaction.createUser(username, dataplus.dictGetSafeVal(request.REQUEST, 'name'), dataplus.dictGetSafeVal(request.REQUEST, 'password1'), dataplus.dictGetSafeVal(request.REQUEST, 'email'), dataplus.dictGetSafeVal(request.REQUEST, 'country'), 'Software/IT', 0, dataplus.dictGetVal(request.REQUEST, 'invitation')) account = models.Account.objects.get(username=username) session_id = sessions_client.query('addNewSession', [account.username]) if session_id: chat_settings = models.ChatSettings.objects.get(account=account) livewire_client.command('updateUserSession', [session_id, account.username, account.name, chat_settings.online_status, chat_settings.custom_message, chat_settings.invite_preference, chat_settings.ignore_list, dataplus.getStaticUrl(chat_settings.image_size1_file_path), dataplus.getStaticUrl(chat_settings.image_size2_file_path), dataplus.getStaticUrl(chat_settings.image_size3_file_path)]) return siteaction.redirectWithCookie('createresume.htm', 'session_id', session_id)
def handle(request): req_id = dataplus.dictGetVal(request.REQUEST, 'reqId', '0', string.atoi) myself = siteaction.getLoggedInUser(request) if not myself: return HttpResponseRedirect('/login.htm?' + urllib.urlencode( {'returnUrl':'/me/approvecommjoinreq.htm?reqId=' + str(req_id)})) join_req = dataplus.returnIfExists(models.CommunityJoinRequest.objects.filter(id=req_id)) if not join_req: return siteaction.render_to_response('me/showmessage.htm', { 'myself':myself, 'msg_heading':'Request not found', 'msg_html':'The community join request does not exist. It must have already been processed.'}) if join_req.community.owner_username != myself.username: return siteaction.render_to_response('me/showmessage.htm', { 'myself':myself, 'msg_heading':'Error', 'msg_html':'Access denied.' }) if request.method == 'GET': return siteaction.render_to_response('me/approvecommjoinreq.htm', {'myself':myself, 'join_req':join_req}) elif request.method == 'POST': allowed = False if dataplus.dictGetVal(request.REQUEST,'result') == 'allow': join_req.sent_by.communities.add(join_req.community) allowed = True flashId = 'comm_join_allowed' else: flashId = 'comm_join_denied' join_req.delete() approved_text = ('denied','approved')[allowed] subject = 'Re: Request to join ' + join_req.community.name html_message = '<p>Your request to join \'' + join_req.community.name + '\' was ' + \ approved_text + ' by the administrator.<p><p>Regards,<br />from Socialray</p>' text_message = 'Your request to join \'' + join_req.community.name + '\' was ' + \ approved_text + ' by the administrator.\r\n\r\nRegards,\r\n from Socialray\r\n\r\n' def internalSender(rcvr_accounts): mailman.sendToInbox(myself.username, rcvr_accounts[0].username, subject, html_message) def externalSender(rcvr_accounts): sender = '"' + myself.name + '" <' + myself.username + '*****@*****.**>' receivers = ['"' + rcvr.name + '" <' + rcvr.email + '>' for rcvr in rcvr_accounts] mailman.sendOneWayMail(sender, receivers, subject, html_message, None, None, text_message) mailman.sendBySettings([join_req.sent_by.account], internalSender, externalSender, 'SocialrayAlert') return HttpResponseRedirect('/me?flashId=' + flashId)
def handle(request): myself = siteaction.getLoggedInUser(request) if not myself: return HttpResponseRedirect( config.server_base_url + "/login.htm?returnUrl=" + config.server_base_url + "/me/editsettings.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"), "" ) return siteaction.render_to_response( "me/editsettings.htm", { "fwd_messages_checked": dataplus.conditionalValue( lambda: settings.email_fwd_messages == True, 'checked="checked"', "" ), "fwd_jobrefs_checked": dataplus.conditionalValue( lambda: settings.email_fwd_jobrefs == True, 'checked="checked"', "" ), "fwd_alerts_checked": dataplus.conditionalValue( lambda: settings.email_fwd_alerts == True, 'checked="checked"', "" ), "action_result": action_result, "myself": myself, }, ) if request.method == "POST": result, errMsg = codejar_validation.validateName(dataplus.dictGetVal(request.REQUEST, "fullname")) if not result: return siteaction.render_to_response( "me/showmessage.htm", {"myself": myself, "msg_heading": "Error", "msg_html": "Invalid user input."} ) myself.name = dataplus.dictGetVal(request.REQUEST, "fullname") myself.account.name = dataplus.dictGetVal(request.REQUEST, "fullname") myself.account.save() myself.save() settings = models.UserSettings.objects.get(user=myself) settings.email_fwd_messages = dataplus.dictGetVal(request.REQUEST, "email_fwd_messages", False, lambda x: True) settings.email_fwd_jobrefs = dataplus.dictGetVal(request.REQUEST, "email_fwd_jobrefs", False, lambda x: True) settings.email_fwd_alerts = dataplus.dictGetVal(request.REQUEST, "email_fwd_alerts", False, lambda x: True) settings.save() return HttpResponseRedirect("/me/editsettings.htm?flashId=acctset_saved")
def handle(request, comm_id): if request.method == 'GET': community = models.Community.objects.get(id=comm_id) myself = siteaction.getLoggedInUser(request) if not myself: return HttpResponseRedirect('/login.htm') if community.owner_username != myself.username: return siteaction.render_to_response('me/showmessage.htm', { 'myself':myself, 'msg_heading':'Error', 'msg_html':'Access denied' }) member_id = dataplus.dictGetVal(request.REQUEST, 'memberId', 0, string.atoi) member = dataplus.returnIfExists(community.members.filter(id=member_id)) if not member: return siteaction.render_to_response('me/showmessage.htm', { 'myself':myself, 'msg_heading':'Error', 'msg_html':'Invalid request' }) action = dataplus.dictGetVal(request.REQUEST, 'action') if not request.has_key('action'): return siteaction.render_to_response('communities/managemember.htm', { 'community':community, 'myself':myself, 'member_thumbnail': getUserThumb(member), 'member':member, }) if action == 'transfer_ownership': community.owner_username = member.username community.save() flashId = 'comm_trnsfr_owner' elif action == 'delete_membership': member.communities.remove(community) flashId = 'comm_del_mem' elif action == 'delete_posts': member.community_posts.all().delete() flashId = 'comm_del_posts' return HttpResponseRedirect(config.communities_url + '/' + str(community.id) + '?flashId=' + flashId) else: #should never have a post :) return siteaction.render_to_response('me/showmessage.htm', { 'myself':myself, 'msg_heading':'Error', 'msg_html':'Access denied' })
def handle(request): try: myself = siteaction.getLoggedInUser(request) if not myself: return ajaxian.getFailureResp('not_logged_in') invite_email = dataplus.dictGetVal(request.REQUEST,'invite_email') is_valid, err_msg = codejar_validation.validateEmail(invite_email) if not is_valid: return ajaxian.getFailureResp('invalid_email') #see if a user with the same email exists user = dataplus.returnIfExists(models.User.objects.filter(email=invite_email)) if user: if user.username == myself.username: return ajaxian.getSuccessResp('cannot_add_self') invitation = models.FriendInvitation(sent_by=myself, sent_to_email=invite_email) invitation.invite_random_key = dataplus.getUniqueId() invitation.save() subject = myself.name + ' has invited you to Socialray' html_file = '/apps/socialray/website/bigfoot/websitetools/mailtemplates/invitation.html' text_file = '/apps/socialray/website/bigfoot/websitetools/mailtemplates/invitation.txt' mailer.sendInvite(html_file, text_file, myself, subject, (invite_email), {'name':lambda x:x.name, 'username':lambda x:x.username, 'message':lambda x:'', 'invite_random_key':lambda x:str(invitation.invite_random_key)}) return ajaxian.getSuccessResp('') except: return ajaxian.getFailureResp('unknown')
def handle(request): try: myself = siteaction.getLoggedInUser(request) if not myself: return ajaxian.getFailureResp('not_logged_in') comm_id = string.atoi(dataplus.dictGetVal(request.REQUEST,'commId')) community = models.Community.objects.get(id=comm_id) title = dataplus.dictGetSafeVal(request.REQUEST,'title') text = dataplus.dictGetSafeVal(request.REQUEST,'text') if community.is_moderated: if not community.members.filter(id=myself.id): return ajaxian.getFailureResp('This is a moderated community. So only members can post.') topic = models.CommunityTopic() topic.community = community topic.title = title topic.started_by = myself topic.last_post_at = datetime.utcnow() topic.save() post = models.CommunityPost() post.topic = topic post.posted_by = myself post.text = text post.save() return ajaxian.getSuccessResp(me_communities_show.getTopicBoxHtml(topic, True)) except: return ajaxian.getFailureResp('unknown')
def fileUploadStart(request, session_id): try: chat_id = dataplus.dictGetVal(request.REQUEST, 'chatId', '') if not chat_id: return ajaxian.getFailureResp('error:invalid_chatId') filename = dataplus.dictGetVal(request.REQUEST, 'filename', '') if not filename: return ajaxian.getFailureResp('error:invalid_filename') result = livewire_client.command('fileUploadStart', [session_id, chat_id, filename]) if result.startswith('error:'): return ajaxian.getFailureResp(result) else: return ajaxian.getSuccessResp('') except: return ajaxian.getFailureResp('error:unknown')
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
def getMessages(request, session_id): try: chat_id = dataplus.dictGetVal(request.REQUEST, 'chatId', '') last_message_id = dataplus.dictGetVal(request.REQUEST, 'lastMessageId','0') if not chat_id: return ajaxian.getFailureResp('error:invalid_chatId') data = livewire_client.query('getChatMessages', [session_id, chat_id, last_message_id]) if data.startswith('error:'): return ajaxian.getFailureResp(data) messages = cPickle.loads(data) return ajaxian.getSuccessResp(messages) #return ajaxian.getSuccessResp('hello') except: return ajaxian.getFailureResp('error:unknown')
def handle(request): try: username = dataplus.dictGetVal(request.REQUEST, 'username') password = dataplus.dictGetVal(request.REQUEST, 'password') if not (username and password): return ajaxian.getFailureResp('Error: Invalid username or password.') success, session_id, redirect_url, error_message = siteaction.doAjaxLogin(username, password) if success: response = ajaxian.getSuccessResp(redirect_url) response.set_cookie('session_id', session_id) return response else: return ajaxian.getFailureResp(error_message) except: return ajaxian.getFailureResp('unknown')
def handle(request): myself = siteaction.getLoggedInUser(request) if not myself: return HttpResponseRedirect('/login.htm') page = dataplus.dictGetVal(request.REQUEST, 'page', 0, string.atoi) start_job_num = page * config.jobs_per_page last_job_num = start_job_num + config.jobs_per_page total_jobs = searchjobs.getMatchingJobsCount(myself) jobs = searchjobs.getMatchingJobs(myself, config.jobs_per_page, start_job_num) if total_jobs == 0: showing_howmany = '0 of 0 matching jobs' else: showing_howmany = str(start_job_num + 1) + '-' + str(start_job_num + len(jobs)) + ' of ' + str(total_jobs) prev_btn = '' next_btn = '' if page != 0: prev_btn = '<td><input class="medium-btn" type="button" name="prev-button" value="PREV" onclick="javascript:window.location.href=\'matchingjobs.htm?page=' + str(page-1) + '\'" /></td>' if last_job_num < total_jobs: next_btn = '<td><input class="medium-btn" type="button" name="next-button" value="NEXT" onclick="javascript:window.location.href=\'matchingjobs.htm?page=' + str(page+1) + '\'" /></td>' buttons = prev_btn + next_btn return siteaction.render_to_response('me/matchingjobs.htm', { 'interesting_jobs': jobs, 'showing_howmany': showing_howmany, 'buttons': buttons, 'myself' : myself })
def handle(request): if request.method == 'GET': return siteaction.render_to_response('forgotpassword.htm') elif request.method == 'POST': accounts = models.Account.objects.filter(username=dataplus.dictGetVal(request.REQUEST,'username')) if (accounts.count() > 0): target_acct = accounts[0] uniqueId = dataplus.getUniqueId() password_change_req = models.PasswordChangeRequest() password_change_req.account = target_acct password_change_req.req_random_key = uniqueId password_change_req.created_at = datetime.datetime.utcnow() password_change_req.save() #Send recovery email... mail_subject = 'Reset your Socialray password' mail_body = '<p>Hello,</p>' mail_body += '<p>You received this email because a Password Reset was requested for your Socialray account. <br />' mail_body += 'Just click the link <a href="' + config.server_base_url + '/resetpassword.htm?' + \ 'passwordChangeKey=' + uniqueId + '"><strong>Reset My Password</strong></a> to change your password.</p>' mail_body += '<p>If you did not request it, you can safely ignore this mail.</p>' mail_body += '<p>Regards,<br />from Socialray</p>' mailman.sendOneWayMail(config.system_email, [target_acct.email], mail_subject, mail_body) return siteaction.render_to_response('showmessage.htm', {'msg_heading': 'Password Reset', 'msg_html': 'A link to recover your password was sent to your email address. ' + \ 'The link will expire in 24 hours. <a href="' + config.server_base_url + '">Back to Homepage</a>.'}) else: return siteaction.render_to_response('forgotpassword.htm', {'error_html': '<p style="color:#FF0000">The username does not exist.</p>'})
def handle(request): myself = siteaction.getLoggedInUser(request) if not myself: return HttpResponseRedirect('/login.htm') page = dataplus.dictGetVal(request.REQUEST, 'page', 0, string.atoi) start_ref_num = page * config.referrals_per_page last_ref_num = start_ref_num + config.referrals_per_page total_referrals = myself.received_referrals.count() referrals = myself.received_referrals.order_by('-created_at')[start_ref_num:last_ref_num] for referral in referrals: referral.preview_text = dataplus.getPreviewText(referral.text) if total_referrals == 0: showing_howmany = '0 of 0 job referrals' else: showing_howmany = str(start_ref_num + 1) + '-' + str(start_ref_num + referrals.count()) + ' of ' + str(total_referrals) prev_btn = '' next_btn = '' if page != 0: prev_btn = '<td><input class="medium-btn" type="button" name="prev-button" value="PREV" onclick="javascript:window.location.href=\'referrals.htm?page=' + str(page-1) + '\'" /></td>' if last_ref_num < total_referrals: next_btn = '<td><input class="medium-btn" type="button" name="next-button" value="NEXT" onclick="javascript:window.location.href=\'referrals.htm?page=' + str(page+1) + '\'" /></td>' buttons = prev_btn + next_btn return siteaction.render_to_response('me/referrals.htm', { 'received_referrals': referrals, 'showing_howmany': showing_howmany, 'buttons': buttons, 'myself' : myself })
def buzzUser(request, session_id): try: chat_id = dataplus.dictGetVal(request.REQUEST, 'chatId', '') if not chat_id: return ajaxian.getFailureResp('error:invalid_chatId') receiver = dataplus.dictGetVal(request.REQUEST, 'receiver') if not receiver: return ajaxian.getFailureResp('error:invalid_parameters') data = livewire_client.command('buzzUser', [session_id, chat_id, receiver]) if data.startswith('error:'): return ajaxian.getFailureResp(data) else: return ajaxian.getSuccessResp('') except: return ajaxian.getFailureResp('error:unknown')