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, username): username = username.lower() #if there is no logged in user, handle the request here. #otherwise, just pass it on to the handler in 'users' or 'recruiters' user_type = siteaction.getLoggedInAccountType(request) if user_type == 'U': return me_viewprofile.handle(request, username) ## if user_type == 'R': ## return recruiters_viewprofile.handle(request, username) else: #this is an anoynymous request, we have to handle user = get_object_or_404(models.User, username=username) settings = models.UserSettings.objects.get(user=user) if settings.resume_visibility != 'everyone': return siteaction.render_to_response('showmessage.htm', {'msg_heading':'Private Profile', 'msg_html':'The user\'s privacy settings do not allow you to view this page. Please <a href="/login.htm">login</a>.'}) online_status = chat.getOnlineStatus(request, [user.username]) online_status_html = '<img class="img_online_status" ' if online_status[user.username] == 'online': online_status_html += 'alt="online" title="Online Now" src="' + config.static_server_base_url + '/site/images/common/livestatus-online-white-bg.gif" /> Online Now' elif online_status[user.username] == 'away': online_status_html += 'alt="away" title="Away" src="' + config.static_server_base_url + '/site/images/common/livestatus-away-white-bg.gif" /> Away' else: online_status_html += 'alt="offline" title="Offline" src="' + config.static_server_base_url + '/site/images/common/livestatus-offline-white-bg.gif" /> Offline' dial_now_number = '' skype_username = '' yahoo_username = '' if settings.enable_voip_dial: dial_now_number = user.phone for msnger in models.WebMessenger.objects.filter(account=user.account): if msnger.provider == 'skype': skype_username = msnger.username elif msnger.provider == 'yahoo': yahoo_username = msnger.username masked = False if settings.phone_num_visibility != 'everyone': masked = True return siteaction.render_to_response('profiles/show.htm', { 'user': user, 'online_status_html':online_status_html, 'dial_now_number':dial_now_number, 'skype_username':skype_username, 'yahoo_username':yahoo_username, 'personal_desc' : dataplus.replaceHtmlLineBreaks(user.personal_desc), 'resume_contents' : codejar_resume.getResumeText(user, masked), 'resume_style_sheet' : codejar_resume.getResumeStyleSheet(user), 'user_image': dataplus.getStaticUrl(user.image_size3_file_path), 'user_original_image': dataplus.getStaticUrl(user.image_file_path), 'testimonials': me_viewprofile.getTestimonials(user), 'resume_questions': me_viewprofile.getResumeQuestions(user), 'interest_in_new_job':settings.interest_in_new_job, })
def saveFile(request, chat_id, field_name): file = None ext = None size = None try: if not request.FILES: return False, 'invalid_upload', '', '', '', '', '' file = request.FILES[field_name] filename = file.name.lower() filename_parts = filename.split('.') if len(filename_parts) == 1: ext = '' else: ext = filename_parts[len(filename_parts) -1] if ext in ['exe', 'vbs', 'wmf']: return False, 'unsupported_file_type', '', '', '', '', '' filecontent = file.read() size = len(filecontent) if size > max_per_file_size: return False, 'large_upload', '', '', '', '', '' #save the main file file_dir = config.website_base_path + '/chat/data/' + chat_id if not os.path.exists(file_dir): os.mkdir(file_dir) filename = getNewFilename(file_dir, filename) file_path = file_dir + '/' + filename f = open(file_path, 'wb') f.write(filecontent) f.close() file_type, thumbnail_url = getFileTypeNThumbnail(ext) if file_type == 'image': try: im = Image.open(file_path).convert('RGB') im.thumbnail((128,128), Image.ANTIALIAS) tmp_path = file_dir + '/preview-' + filename im.save(tmp_path, 'JPEG') thumbnail_url = dataplus.getStaticUrl(tmp_path) except: pass return True, '', filename, dataplus.getStaticUrl(file_path), file_type, size, thumbnail_url except: logError('File upload error: ' + str(sys.exc_info()[0]) + ', ' + str(sys.exc_info()[1])) return False, 'unknown', '', '', '', '', ''
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 getCommunitySmallThumb(community): comm_url = config.communities_url + '/' + str(community.id) html = '<div class="pic-thumb"><a href="' + comm_url + '">' + \ '<img src="' + dataplus.getStaticUrl(community.image_size2_file_path) + '" alt="' + community.name + '" /></a>' + \ '<br /><a class="small-text" href="' + comm_url + '">' + \ community.name + '</a></div>' return html
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 makeMembersBoxHtml(community, members): num_cols = 3 html = '<table class="split-lpane-section-table">' col_ctr = 0 for member in members: if col_ctr == 0: html += "<tr>" member_url = config.profiles_url + "/" + member.account.username html += '<td class="section-col"><table width="100%"><tr><td><div align="center">' html += '<a href="' + member_url + '"><img src="' + dataplus.getStaticUrl(member.image_size2_file_path) html += '" alt="' + member.name + '" /></a></div></td></tr><tr><td><div align="center"><a href="' html += member_url + '">' + member.name + "</a></div></td></tr></table></td>" if col_ctr == num_cols - 1: html += "</tr>" col_ctr = 0 else: col_ctr += 1 if col_ctr != 0: for i in range(0, num_cols - col_ctr): html += '<td class="section-col"/>' html += "</tr>" html += "</table>\r\n" if members: html += ( '<table class="thin-button-box"><tr>' + '<td><input class="large-btn" type="button" name="view-all-btn" value="View All" onclick="window.location.href=\'members.htm\';" /></td>' + '<td><input class="large-btn" name="send-job-ref-button" value="Send Job Referral" onclick="javascript:window.location.href=\'/me/sendjobreferral.htm?rcvrId=' + str(community.id) + '&rcvrType=c\';" type="button" /></td>' + "</tr></table>" ) return html
def getFriendReqBoxHtml(user): #get all friend requests friend_requests = models.FriendRequest.objects.filter(sent_to__id=user.id) has_requests = False html = '' for req in friend_requests: has_requests = True html += '<div class="friend-request-item" id="friend-req-' + str(req.id) + '">' #column 1: Image of Sender html += '<table><tr>' html += '<td style="width:72px;"><div><a href="/profiles/' + req.sent_by.account.username + '">' + \ '<img alt="' + req.sent_by.name +'" src="' + dataplus.getStaticUrl(req.sent_by.image_size2_file_path) +'" />' + \ '</a></div></td>' html += '<td style="width:220px;">' + \ '<a href="/profiles/' + req.sent_by.account.username + '" style="padding-left:8px;"><span class="big-text">' + req.sent_by.name + '</span></a>' + \ '<table><tr>' + \ '<td><input class="small-btn" type="button" name="accept-btn" value="Accept" onclick="acceptFriendReq(' + str(req.id) + ')" /></td>' + \ '<td><input class="small-btn" type="button" name="reject-btn" value="Reject" onclick="rejectFriendReq(' + str(req.id) + ')" /></td>' + \ '</tr></table>' + \ '</td>' html += '</tr></table></div>' return has_requests, html
def makeFriendsListHtml(friends, request): friends_usernames = [user.username for user in friends] online_status = chat.getOnlineStatus(request, friends_usernames, 'friend') html = '<tr>' for friend in friends: friend_url = config.profiles_url + '/' + friend.account.username html += '<td class="section-col"><table width="100%">' #show line 1: photos html += '<tr><td><div align="center">' + \ '<a href="' + friend_url + '"><img src="' + \ dataplus.getStaticUrl(friend.image_size1_file_path) + '" alt="' + friend.name + '" /></a>' + \ '</div></td></tr>' #show line 2: name + url html += '<tr><td><div class="small-text" style="line-height:14px;vertical-align:top;text-align:center;">' html += '<a href="' + friend_url + '">' + friend.name + '</a> ' #html += '<img class="img_online_status" id="online_status_' + friend.username + \ # '" style="cursor:pointer;" onclick="javascript:openChatWindow(\'' +friend.username + '\');" ' #if online_status[friend.username] == 'online': # html += 'alt="online" title="Click to chat now" src="' + config.static_server_base_url + '/site/images/common/livestatus-online.gif" />' #elif online_status[friend.username] == 'away': # html += 'alt="away" title="Away" src="' + config.static_server_base_url + '/site/images/common/livestatus-away.gif" />' #else: # html += 'alt="offline" title="Offline" src="' + config.static_server_base_url + '/site/images/common/livestatus-offline.gif" />' html += '</div></td></tr>' html += '</table></td>' for i in range(0, 3 - len(friends)): html += '<td class="section-col"/>' html += '</tr>' return html
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, comm_id, topic_id): myself = siteaction.getLoggedInUser(request) if not myself: return HttpResponseRedirect('/login.htm') community = models.Community.objects.select_related().get(id=comm_id) if community.is_moderated: if (community.members.filter(id=myself.id).count() == 0): return siteaction.render_to_response('showmessage.htm', { 'msg_heading':'Error', 'msg_html':'Access denied.'}) page_num = dataplus.dictGetVal(request.REQUEST, 'page', 1, string.atoi) topic = models.CommunityTopic.objects.select_related().get(id=topic_id) paginator = Paginator(topic.posts.all().order_by('-posted_on'), config.posts_per_page) page = paginator.page(page_num) if paginator.count == 0: showing_howmany = '0 of 0 posts' else: showing_howmany = str(page.start_index()) + '-' + str(page.end_index()) + ' of ' + str(paginator.count) for post in page.object_list: post.text = dataplus.replaceHtmlLineBreaks(post.text) post.posted_by.image_url = dataplus.getStaticUrl(post.posted_by.image_size1_file_path) post.posted_by.profile_url = config.profiles_url + '/' + post.posted_by.username post.posted_on_relative = dataplus.getRelativeDateTime(post.posted_on) prev_btn = '' next_btn = '' if page_num != 1: prev_btn = '<td><input class="medium-btn" type="button" name="prev-btn" value="Prev" onclick="javascript:window.location.href=\'?page=' + str(page_num-1) + '\';" /></td>' if page.has_next(): next_btn = '<td><input class="medium-btn" type="button" name="next-btn" value="Next" onclick="javascript:window.location.href=\'?page=' + str(page_num+1) + '\';" /></td>' buttons = prev_btn + next_btn community.image_url = dataplus.getStaticUrl(community.image_size2_file_path) return siteaction.render_to_response('communities/posts.htm', { 'myself': myself, 'community': community, 'topic': topic, 'posts': page.object_list, 'community_snapshot': getCommunitySnapshotHtml(community), 'showing_howmany': showing_howmany, 'buttons': buttons, })
def getInterestingComms(forWhom): results = [] comm_matches = models.Community.objects.order_by('?')[:5] for match in comm_matches: match.image_url = dataplus.getStaticUrl(match.image_size2_file_path) results.append(match) return results
def getCommunityMemberThumb(member, community, manage): html = '<div class="descriptive-thumb"><a href="' + config.profiles_url + '/' + member.username + '">' + \ '<img src="' + dataplus.getStaticUrl(member.image_size2_file_path) + '" alt="' + member.name + '" /></a>' + \ '<h4><a href="' + config.profiles_url + '/' + member.username + '">' + member.name + '</a></h4>' if manage: html += '<a href="' + config.communities_url + '/' + str(community.id) + '/managemember.htm?memberId=' + \ str(member.id) + '">manage</a><br />' html += dataplus.getPreviewText(member.small_desc, 50) + '</div>' return html
def getInterestingUsers(forWhom): results = [] # for now, let us just show some users randomly! username_matches = models.User.objects.filter(account__account_state="A").order_by("?")[:5] for match in username_matches: if match.username == forWhom.username: continue match.image_url = dataplus.getStaticUrl(match.image_size2_file_path) results.append(match) return results
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 handle(request): chat_id = dataplus.dictGetVal(request.REQUEST, 'chatId') if not chat_id: return siteaction.render_to_response('404.html') result = livewire_client.query('getChatMembers', [chat_id]) if result.startswith('error:'): return siteaction.render_to_response('404.html') chat_members = cPickle.loads(result) if chat_members: html = '<table style="width:460px">\r\n' for member_info in chat_members: member_data = member_info.split(':') if member_data[0].startswith('#'): html += '<tr>\r\n<td style="text-align:center;width:160px;vertical-align:top">' + \ '<img src="' + dataplus.getStaticUrl(config.chat_guest_img_72) + '" alt="guest" />' + \ '<br />' + member_data[1] + '</td>' + \ '<td style="width:300px;"><span class="small-text" style="text-align:justify">' + \ 'Guest</span></td>\r\n</tr>\r\n' else: account = models.Account.objects.get(username=member_data[0]) image_url = '' small_desc = '' if account.account_type == 'U': user = models.User.objects.get(account=account) image_url = dataplus.getStaticUrl(user.image_size2_file_path) small_desc = dataplus.getPreviewText(user.hilite,200) elif account_type == 'A': pass html += '<tr>\r\n<td style="text-align:center;width:160px;vertical-align:top">' + \ '<a href="/profiles/' + account.username + '" >' + \ '<img src="' + image_url + '" alt="' + account.name + '" /></a><br />' + \ '<a href="/profiles/' + account.username + '" >' + account.name + '</a></td>' + \ '<td style="width:300px;"><span class="small-text" style="text-align:justify">' + \ small_desc + '</span></td>\r\n</tr>\r\n' html += '</table>\r\n' return siteaction.render_to_response('chat/startchat.htm', {'chat_id':chat_id, 'chat_members_html':html})
def blockUser(request, session_id): try: username = dataplus.dictGetVal(request.REQUEST, 'username', '') if not username: return ajaxian.getFailureResp('error:empty_username') account = siteaction.getLoggedInAccount(request) if not account: return ajaxian.getFailureResp('error:not_logged_in') cs = models.ChatSettings.objects.get(account=account) ignore_list = cs.ignore_list.split(',') if not username in ignore_list: ignore_list.append(username); cs.ignore_list = string.join(ignore_list, ',') cs.save() livewire_client.command('updateUserSession', [session_id, account.username, account.name, cs.online_status, cs.custom_message, cs.invite_preference, cs.ignore_list, dataplus.getStaticUrl(cs.image_size1_file_path), dataplus.getStaticUrl(cs.image_size2_file_path), dataplus.getStaticUrl(cs.image_size3_file_path)]) return ajaxian.getSuccessResp('') except: return ajaxian.getFailureResp('error:unknown')
def getCommunityDescBlock(community): comm_url = config.communities_url + '/' + str(community.id) comm_type = ('Public','Moderated')[community.is_moderated] comm_owner = models.User.objects.get(username=community.owner_username) html = '<div class="hilited-block"><table style="width:100%"><tr>' + \ '<td style="width:84px;"><a href="' + comm_url + '">' + \ '<img src="' + dataplus.getStaticUrl(community.image_size2_file_path) + '" alt="' + community.name + '" /></a></td>' + \ '<td style="vertical-align:top"><h4><a href="' + comm_url + '">' + community.name + '</a></h4>' + \ '<p>' + community.desc +'<br/>' + \ comm_type + ' Community, Owner: <a href="' + config.profiles_url + '/' + community.owner_username + '">' + comm_owner.name + '</a><br/>\r\n' + \ '<strong>Created:</strong> ' + community.created_on.strftime("%m/%d/%Y") + ', <strong>Members:</strong> ' + str(community.members.count()) + '</p>\r\n' + \ '</td></tr></table></div>\r\n' return html
def getDescriptiveThumb(user, show_online_status=False, online_status='offline'): html = '<div class="descriptive-thumb"><a href="' + config.profiles_url + '/' + user.username + '">' + \ '<img src="' + dataplus.getStaticUrl(user.image_size2_file_path) + '" alt="' + user.name + '" /></a>' + \ '<div class="medium-text"><a href="' + config.profiles_url + '/' + user.username + '">' + user.name + '</a> ' #if show_online_status: # html += '<img class="img_online_status" id="online_status_' + user.username + '" style="cursor:pointer;" onclick="javascript:openChatWindow(\'' + user.username + '\');" ' # if online_status == 'online': # html += 'alt="online" title="Click to chat now" src="' + config.static_server_base_url + '/site/images/common/livestatus-online.gif" />' # elif online_status == 'away': # html += 'alt="away" title="Away" src="' + config.static_server_base_url + '/site/images/common/livestatus-away.gif" />' # else: # html += 'alt="offline" title="Offline" src="' + config.static_server_base_url + '/site/images/common/livestatus-offline.gif" />' html += '</div>' + dataplus.getPreviewText(user.small_desc, 112) + '</div>' return html
def handle(request): if request.method == 'GET': return siteaction.render_to_response('recruiters/resumesearch.htm', {'industry_cats_html': getIndustryCatsHtml(), 'salary_range_select_html':getSalaryRangeSelectHtml(), 'exp_range_select_html':getExpRangeSelectHtml(), 'locations_select_html':getLocationsSelectHtml() }) elif request.method == 'POST': industry_category = dataplus.dictGetVal(request.REQUEST,'industry_category') keywords = dataplus.dictGetVal(request.REQUEST,'keywords') min_exp_years = dataplus.dictGetVal(request.REQUEST,'min_exp_years', None, string.atoi) location = dataplus.dictGetVal(request.REQUEST,'location') salary_range = dataplus.dictGetVal(request.REQUEST,'salary_range') 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: query = makeSearchQuery(keywords, industry_category, min_exp_years, location, salary_range) match_list = searchpeople.getMatchesEx(query) pickled_match_list = cPickle.dumps(match_list) page = 0 display_list = match_list[page * config.user_matches_per_page:((page + 1) * config.user_matches_per_page)] users_bulk_dict = models.User.objects.in_bulk(display_list) num_pages = ((len(match_list)-1)/config.user_matches_per_page) + 1 matching_users = dataplus.getOrderedList(users_bulk_dict, display_list) for user in matching_users: user.image_url = dataplus.getStaticUrl(user.image_size2_file_path) return siteaction.render_to_response('recruiters/resumesearch.htm', {'showing_search_results': True, 'keywords': keywords, 'industry_cats_html': getIndustryCatsHtml(industry_category), 'salary_range_select_html':getSalaryRangeSelectHtml(salary_range), 'exp_range_select_html':getExpRangeSelectHtml(dataplus.dictGetVal(request.REQUEST,'min_exp_years')), 'locations_select_html':getLocationsSelectHtml(location), 'matching_users':matching_users, 'matches': cgi.escape(pickled_match_list), 'page_links_html': getPageLinksHtml(num_pages, page), })
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_size2_file_path) return siteaction.render_to_response('communities/editinfo.htm', {'community':community, 'action_result':action_result, 'myself':myself}) elif request.method == 'POST': comm_name = dataplus.dictGetSafeVal(request.REQUEST, 'name') comm_desc = dataplus.dictGetSafeVal(request.REQUEST, 'desc') if comm_name != community.name: result, errMsg = codejar_validation.validateCommunityName(comm_name) if not result: return siteaction.render_to_response('communities/editinfo.htm', {'community':community, 'myself':myself, 'action_result':'Invalid Community Name. ' + errMsg,}) if codejar_network.checkCommunityNameExists(comm_name): return siteaction.render_to_response('communities/editinfo.htm', {'community':community, 'myself':myself, 'action_result':dataplus.dictGetVal(statix.action_messages, 'comm_name_exists', ''), }) community.name = comm_name community.desc = comm_desc community.save() return HttpResponseRedirect('./?flashId=comm_settings_chnged')
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 community.is_moderated: if (community.members.filter(id=myself.id).count() == 0): return siteaction.render_to_response('showmessage.htm', { 'msg_heading':'Error', 'msg_html':'Access denied.'}) page_num = dataplus.dictGetVal(request.REQUEST, 'page', 1, string.atoi) paginator = Paginator(community.topics.all().order_by('-started_on'), config.topics_per_page) page = paginator.page(page_num) if paginator.count == 0: showing_howmany = '0 of 0 topics' else: showing_howmany = str(page.start_index()) + '-' + str(page.end_index()) + ' of ' + str(paginator.count) prev_btn = '' next_btn = '' if page_num != 1: prev_btn = '<td><input class="medium-btn" type="button" name="prev-btn" value="PREV" onclick="javascript:window.location.href=\'topics.htm?page=' + str(page_num-1) + '\';" /></td>' if page.has_next(): next_btn = '<td><input class="medium-btn" type="button" name="next-btn" value="NEXT" onclick="javascript:window.location.href=\'topics.htm?page=' + str(page_num+1) + '\';" /></td>' buttons = prev_btn + next_btn community.image_url = dataplus.getStaticUrl(community.image_size2_file_path) return siteaction.render_to_response('communities/topics.htm', { 'myself': myself, 'community': community, 'community_snapshot': getCommunitySnapshotHtml(community), 'topics_html': me_communities_show.makeTopicsBoxHtml(page.object_list, True), 'showing_howmany': showing_howmany, 'buttons': buttons, })
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/editsocialprofile.htm', {'action_result':action_result, 'myself': myself }) elif request.method == 'POST': success, error_code = codejar_network.saveSocialProfile(request, myself) if not success: return HttpResponseRedirect('/me/editsocialprofile.htm?flashId=' + error_code) redirect_file = ('/me/editjobsettings.htm', '/me')[dataplus.dictGetVal(request.REQUEST, 'action', '') == 'create'] return HttpResponseRedirect('/me/editsocialprofile.htm?flashId=soc_saved')
def getCommunities(page_type="", ref_id=0): communities = [] has_more = False if page_type == "next": communities = models.Community.objects.filter(id__lt=ref_id).order_by("-id")[: config.members_per_page + 1] elif page_type == "prev": communities = models.Community.objects.filter(id__gt=ref_id).order_by("id")[: config.members_per_page + 1] else: communities = models.Community.objects.all().order_by("-id")[: config.members_per_page + 1] communities = list(communities) if len(communities) > config.members_per_page: has_more = True communities = communities[:-1] if page_type == "prev": communities.reverse() for comm in communities: comm.image_url = dataplus.getStaticUrl(comm.image_size2_file_path) return communities, has_more
def makeCommBoxHtml(communities): html = '<tr>' for community in communities: comm_url = config.communities_url + '/' + str(community.id) html += '<td class="section-col"><table width="100%">' #show line 1: photos html += '<tr><td><div align="center">' + \ '<a href="' + comm_url + '"><img src="' + \ dataplus.getStaticUrl(community.image_size1_file_path) + '" alt="' + community.name + '" /></a>' + \ '</div></td></tr>' #show line 2: name + url html += '<tr><td><div class="small-text" style="line-height:14px;" align="center"><a href="' + comm_url + '">' + community.name + \ '(' + str(community.members.count()) + ')</a></div></td></tr>' html += '</table></td>' for i in range(0, 3 - len(communities)): html += '<td class="section-col"/>' html += '</tr>' return html
def handle(request, username): myself = siteaction.getLoggedInRecruiter(request) if not myself: return HttpResponseRedirect('/login.htm') user = models.User.objects.get(account__username=username) resume_contents = codejar_resume.getResumeText(user) testimonials = user.testimonials_for_me.all() return render_to_response('recruiters/viewprofile.htm', { 'username': user.username, 'user_full_name': user.name, 'user_description': user.personal_desc, 'resume_contents' : resume_contents, 'userid': user.id, 'user_image': dataplus.getStaticUrl(user.image_size3_file_path), 'testimonials': testimonials, 'users_friends': getFriends(user), 'users_communities': getCommunities(user), 'myself': myself })
def getCommunityInfoHtml(community, user): comm_type = ("Public", "Moderated")[community.is_moderated] comm_owner = models.User.objects.get(username=community.owner_username) html = "<table>\r\n<tr>\r\n<td>" html += ( '<div align="center" style="padding:8px"><img src="' + dataplus.getStaticUrl(community.image_size3_file_path) + '" alt="' + community.name + '" />' ) if user and comm_owner.username == user.username: html += '<br /><a class="small-text" href="changephoto.htm">Change photo</a>' html += "</div></td>\r\n" if user and comm_owner.username == user.username: html += '<td style="padding:8px 0px 0px 8px;vertical-align:top;"><br />> <a href="editinfo.htm">Edit Info</a></td>\r\n' html += "</tr>\r\n</table>\r\n" html += "<div>" + community.desc + "<br />\r\n" html += ( "<strong>" + comm_type + '</strong>, Owner: <a href="' + config.profiles_url + "/" + community.owner_username + '">' + comm_owner.name + "</a><br />\r\n" ) html += ( "<strong>Created:</strong> " + community.created_on.strftime("%m/%d/%Y") + ", <strong>Members:</strong> " + str(community.members.count()) + "</div>\r\n" ) return html
def getCommunitySnapshotHtml(community): comm_url = config.communities_url + '/' + str(community.id) html = '<div align="center" style="padding:8px"><a href="' + comm_url + '">' html += '<img src="' + dataplus.getStaticUrl(community.image_size3_file_path) + '" alt="' + community.name + '" />' html += '</a><br /><a href="' + comm_url + '">' + community.name + '</a></div>' return html
def getMatchingUsers(): users = models.User.objects.all() for usr in users: usr.image_url = dataplus.getStaticUrl(usr.image_size2_file_path) return users
def getProfileSnapshotHtml(user): html = '<div align="center" style="padding:8px">' +\ '<img src="' + dataplus.getStaticUrl(user.image_size2_file_path) + '" alt="' + user.name + '" />' + \ '<br /><a href="changephoto.htm" class="small-text">Change Photo</a></div>' return html