コード例 #1
0
ファイル: me_referrals.py プロジェクト: TayebJa3ba/socialray
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 })
コード例 #2
0
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
コード例 #3
0
def saveSocialProfile(request, user):
    personal_desc = dataplus.dictGetSafeVal(request.REQUEST, 'personaldesc', '')
    
    user.personal_desc = personal_desc
    
    if request.FILES:
        img_save_success, error_code, img1, img2, img3, img4 = \
            studio.saveImage_x4_ByDate(request, 'user_' + user.username, 'photograph')
        if img_save_success:
            if user.image_file_path != img1:
                iolib.deleteFiles([user.image_file_path, user.image_size1_file_path, 
                    user.image_size2_file_path, user.image_size3_file_path])
                user.image_file_path = img1
                user.image_size1_file_path = img2
                user.image_size2_file_path = img3
                user.image_size3_file_path = img4
                
                chat_settings = models.ChatSettings.objects.get(account=user.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()
        else:
            return img_save_success, error_code

    if not dataplus.isNullOrEmpty(user.personal_desc):
        user.hilite = dataplus.getPreviewText(personal_desc, 512)
        user.small_desc = dataplus.getPreviewText(personal_desc, 256)
    else:
        #if personal_desc is null AND resume_contents.text is ALSO null
        if dataplus.isNullOrEmpty(user.resume_contents.text):
            user.hilite = config.no_details_text
            user.small_desc = config.no_details_text
    if personal_desc:
        codejar_resume.updatePlainTextResume(user)
                
    user.last_updated_time = datetime.datetime.utcnow()
    user.save()
    
    return True, ''
コード例 #4
0
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
コード例 #5
0
def getMessageBoxHtml(rec):
    html = ''
    msgs = models.Message.objects.filter(account__id=rec.account.id, folder='inbox').order_by('-sent_at')[:6]
    ctr = 0
    for msg in msgs:
        ctr = ctr + 1
        if msg.message_type == 'JR':
            #TODO: Complete!
            pass
        if msg.message_type == 'TM':
            msg_row_id = 'email' + str(ctr)
            msg_row_xp_id = 'emailxp' + str(ctr)
            msg_reply_box = 'email_reply_box-' + str(ctr)
            
            if msg.sender.account_type == 'U':
                sender_url = config.profiles_url + '/' + msg.sender.username
            elif msg.sender.account_type == 'R':
                rec = msg.sender.recruiter.all()[0]
                sender_url = config.recruiters_url + '/' + str(rec.id)

            html += '<div id="' + msg_row_id + '" class="email-msg-item">\r\n'
            html += '<table class="msg-item-table"><tr>\r\n' + \
                        '<td class="msg-from-field"><a href="' + sender_url + '">' + msg.sender.name + ' </a></td>\r\n' + \
                        '<td class="msg-subject"><span class="linkless" onclick="javascript:viewMessage(\'' + str(msg.id) + '\', \'' + msg_row_xp_id + '\', \'' + msg_row_id + '\');">'
            if not msg.read:
                html += '<strong>' + msg.subject + '</strong>'
            else:
                html += msg.subject
            html += '</span><span class="dimmed-text"> ' + dataplus.getPreviewText(msg.body, 30) + '</span></td>\r\n' + \
                    '</tr></table>\r\n'
            html += '</div>\r\n'
            
            html += '<div id="' + msg_row_xp_id + '" class="email-msg-xp" style="display:none">\r\n'
            html += '<div style="font-size:14px;font-weight:bold">\r\n' + \
                        '<a href="' + sender_url + '">' + msg.sender.name + '</a> - ' \
                        '<span class="linkless" onclick="javascript:fx_flipElem(\'' + msg_row_xp_id + '\', \'' + msg_row_id + '\');">'+ msg.subject +'</span>' + \
                    '</div>\r\n' + msg.body + '\r\n' \
                    '<table><tr>\r\n' + \
                        '<td class="small-btn" onclick="javascript:showSendMsgBox(\'' + msg_reply_box + '\', \'' + msg.sender.username + '\', \'Re: ' + msg.subject + '\', \'' + str(msg.id) + '\');">Reply</td>' + \
                        '<td class="small-btn" onclick="javascript:fx_flipElem(\'' + msg_row_xp_id + '\', \'' + msg_row_id + '\');">Hide</td>' + \
                        '<td class="small-btn" onclick="javascript:deleteMessage(\'' + str(msg.id) + '\', \'' + msg_row_xp_id + '\');">Delete</td>' + \
                    '</tr></table>\r\n'
            html += '<div id="' + msg_reply_box + '"></div>\r\n'
            html += '</div>\r\n'
    return html
コード例 #6
0
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})
コード例 #7
0
ファイル: me_index.py プロジェクト: TayebJa3ba/socialray
def getMessageBoxHtml(msgs):
    if not msgs:
        return ''
    
    html = ''    
    for msg in msgs:
        msg_row_id = 'email' + str(msg.id)
        msg_row_xp_id = 'emailxp' + str(msg.id)
        msg_reply_box = 'email_reply_box-' + str(msg.id)
        
        if msg.message_type == 'SA':
            html += '<div id="' + msg_row_id + '" class="email-msg-item">\r\n'
            html += '<table class="msg-item-table"><tr>\r\n' + \
                        '<td class="msg-from-field">Socialray </td>\r\n' + \
                        '<td class="msg-subject"><span class="linkless" onclick="javascript:viewMessage(\'' + str(msg.id) + '\', \'' + msg_row_xp_id + '\', \'' + msg_row_id + '\');">'
            if not msg.read:
                html += '<strong>' + msg.subject + '</strong>'
            else:
                html += msg.subject
            html += '</span>'
            if msg.body.strip():    html += '<span class="dimmed-text"> ' + dataplus.getPreviewText(msg.body) + '</span>'
            html += '</td>\r\n' + \
                    '<td class="msg-datetime-field">' + dataplus.getShortRelativeDateTime(msg.sent_at) + '</td>\r\n' + \
                    '</tr></table>\r\n'
            html += '</div>\r\n'
            
            html += '<div id="' + msg_row_xp_id + '" class="email-msg-xp" style="display:none">\r\n'
            html += '<div style="font-size:12px;font-weight:bold">\r\nSocialray - ' \
                        '<span class="linkless" onclick="javascript:fx_flipElem(\'' + msg_row_xp_id + '\', \'' + msg_row_id + '\');">'+ msg.subject +'</span>' + \
                    '</div>\r\n<div class="small-text" style="color:#999999;">' + \
                    dataplus.getRelativeDateTime(msg.sent_at) + '</div>\r\n'  + msg.body + '\r\n' \
                    '<table><tr>\r\n' + \
                        '<td><input class="small-btn" type="button" name="finish" value="Hide" onclick="javascript:fx_flipElem(\'' + msg_row_xp_id + '\', \'' + msg_row_id + '\');" /></td>' + \
                        '<td><input class="small-btn" type="button" name="finish" value="Delete" onclick="javascript:deleteMessage(\'' + str(msg.id) + '\', \'' + msg_row_xp_id + '\');" /></td>' + \
                    '</tr></table>\r\n'
            html += '</div>\r\n'
            
        elif msg.message_type == 'TM':
            if msg.sender.account_type == 'U':
                sender_url = config.profiles_url + '/' + msg.sender.username
            elif msg.sender.account_type == 'R':
                rec = msg.sender.recruiter.all()[0]
                sender_url = config.recruiters_url + '/' + str(rec.id)

            html += '<div id="' + msg_row_id + '" class="email-msg-item">\r\n'
            html += '<table class="msg-item-table"><tr>\r\n' + \
                        '<td class="msg-from-field"><a href="' + sender_url + '">' + msg.sender.name + ' </a></td>\r\n' + \
                        '<td class="msg-subject"><span class="linkless" onclick="javascript:viewMessage(\'' + str(msg.id) + '\', \'' + msg_row_xp_id + '\', \'' + msg_row_id + '\');">'
            if not msg.read:
                html += '<strong>' + msg.subject + '</strong>'
            else:
                html += msg.subject
            html += '</span>'
            if msg.body.strip():    html += '<span class="dimmed-text"> ' + dataplus.getPreviewText(msg.body) + '</span>'
            html += '</td>\r\n' + \
                    '<td class="msg-datetime-field">' + dataplus.getShortRelativeDateTime(msg.sent_at) + '</td>\r\n' + \
                    '</tr></table>\r\n'
            html += '</div>\r\n'
            
            reply_subject = msg.subject.replace("'", "\\'")
            if not reply_subject.startswith('Re: Re: '):
                reply_subject = 'Re: ' + reply_subject
            html += '<div id="' + msg_row_xp_id + '" class="email-msg-xp" style="display:none">\r\n'
            html += '<div style="font-size:12px;font-weight:bold">\r\n' + \
                        '<a href="' + sender_url + '">' + msg.sender.name + '</a> - ' \
                        '<span class="linkless" onclick="javascript:fx_flipElem(\'' + msg_row_xp_id + '\', \'' + msg_row_id + '\');">'+ msg.subject +'</span>' + \
                    '</div>\r\n<div class="small-text" style="color:#999999;">' + \
                    dataplus.getRelativeDateTime(msg.sent_at) + '</div>\r\n' + msg.body + '\r\n' \
                    '<table><tr>\r\n' + \
                        '<td><input class="small-btn" type="button" name="finish" value="Reply" onclick="javascript:showSendMsgBox(\'' + msg_reply_box + '\', \'' + msg.sender.username + '\', \'' + reply_subject + '\', \'' + str(msg.id) + '\');" /></td>' + \
                        '<td><input class="small-btn" type="button" name="finish" value="Hide" onclick="javascript:fx_flipElem(\'' + msg_row_xp_id + '\', \'' + msg_row_id + '\');" /></td>' + \
                        '<td><input class="small-btn" type="button" name="finish" value="Delete" onclick="javascript:deleteMessage(\'' + str(msg.id) + '\', \'' + msg_row_xp_id + '\');" /></td>' + \
                    '</tr></table>\r\n'
            html += '<div id="' + msg_reply_box + '"></div>\r\n'
            html += '</div>\r\n'
    return html
コード例 #8
0
def getMessageBoxHtml(request, tom):
    page_num = dataplus.dictGetVal(request.REQUEST, 'page', 1, string.atoi)

    paginator = Paginator(models.Message.objects.filter \
        (account__id=tom.account.id, folder='outbox') \
        .order_by('-sent_at'), config.messages_per_page)

    if paginator.num_pages == 0: return ''
    
    page = paginator.page(page_num)
    
    html = ''
    ctr = 0
    html += '<div>'
    for msg in page.object_list:
        ctr = ctr + 1
        chk_id = 'chkMsg_' + str(msg.id)
        peers = mailman.getReceiverList(msg)
        peers_html = string.join(['<a href="' + siteaction.getDetailsUrl(x) + '">' + x.name + '</a>' for x in peers], ', ')
        
        if msg.message_type == 'JR':
            #TODO: Finish this ......
            pass
        if msg.message_type == 'TM':
            msg_row_id = 'email' + str(ctr)
            msg_row_xp_id = 'emailxp' + str(ctr)

            html += '<div id="' + msg_row_id + '" class="email-msg-item">\r\n'
            html += '<table class="msg-item-table"><tr>\r\n' + \
                        '<td class="msg-selection"><input id="' + chk_id + '" class="msg-selection-check" name="' + chk_id + '" type="checkbox" value="checked" /></td>\r\n' + \
                        '<td class="msg-from-field">' + peers_html.split('</a>')[0] + '</a>...' + '</td>\r\n' + \
                        '<td class="msg-subject"><span class="linkless" onclick="javascript:fx_flipElem(\'' + msg_row_id + '\', \'' + msg_row_xp_id + '\');">' + msg.subject + '</span>'
            if msg.body.strip():
                html += '<span class="dimmed-text"> ' + dataplus.getPreviewText(msg.body) + '</span>'
            html += '</td>\r\n' + \
                         '<td class="msg-datetime-field">' + dataplus.getShortRelativeDateTime(msg.sent_at) + '</td>' + \
                   '</tr></table>\r\n'
            html += '</div>\r\n'
           
            html += '<div id="' + msg_row_xp_id + '" class="email-msg-xp" style="display:none">\r\n'
            html += '<div style="font-size:12px;font-weight:bold">\r\n' + peers_html + ' - ' \
                        '<span class="linkless" onclick="javascript:fx_flipElem(\'' + msg_row_xp_id + '\', \'' + msg_row_id + '\');">'+ msg.subject + '</span>' + \
                    '</div>\r\n<div class="small-text" style="color:#999999;">' + \
                    dataplus.getRelativeDateTime(msg.sent_at) + '</div>\r\n' + msg.body + '\n' \
                    '<table><tr>\r\n' + \
                        '<td><input class="small-btn" type="button" name="hide-btn" value="Hide" onclick="javascript:fx_flipElem(\'' + msg_row_xp_id + '\', \'' + msg_row_id + '\');" /></td>' + \
                        '<td><input class="small-btn" type="button" name="delete-btn" value="Delete" onclick="javascript:deleteMessage(\'' + str(msg.id) + '\', \'' + msg_row_xp_id + '\');" /></td>' + \
                    '</tr></table>\r\n'
            html += '</div>\r\n'            
                    
    html += '</div>\r\n'        
    html += '<div>'
    if paginator.count > 0:
        html += '<p><span style="color:#999999">Showing ' + str(page.start_index()) + '-' + str(page.end_index()) + \
            ' of ' + str(paginator.count) + ' </span></p>'

    html += '<table class="button-box"><tr>\r\n'
    if page_num != 1:
        html += '<td><input class="medium-btn" type="button" name="prev-btn" value="Prev" onclick="javascript:window.location.href=\'/mailbox/sentitems.htm?page=' + str(page_num-1) + '\';" /></td>\r\n'
    if page.has_next():
        html += '<td><input class="medium-btn" type="button" name="prev-btn" value="Next" onclick="javascript:window.location.href=\'/mailbox/sentitems.htm?page=' + str(page_num+1) + '\';" /></td>\r\n'
    html += '</tr></table>\r\n'

    html += '</div>'
    return html
コード例 #9
0
def getMessageBoxHtml(request, tom):
    page_num = dataplus.dictGetVal(request.REQUEST, 'page', 1, string.atoi)

    paginator = Paginator(models.Message.objects.filter \
        (account__id=tom.account.id, folder='trashcan') \
        .order_by('-sent_at'), config.messages_per_page)

    if paginator.num_pages == 0: return ''
    
    page = paginator.page(page_num)
    
    html = ''
    ctr = 0
    html += '<div>'
    for msg in page.object_list:
        ctr = ctr + 1
        chk_id = 'chkMsg_' + str(msg.id)
       
        if msg.message_type == 'SA':
            msg_row_id = 'email' + str(ctr)
            msg_row_xp_id = 'emailxp' + str(ctr)

            html += '<div id="' + msg_row_id + '" class="email-msg-item">\r\n'
            html += '<table class="msg-item-table"><tr>\r\n' + \
                        '<td class="msg-selection" ><input id="' + chk_id + '" name="' + chk_id + '" class="msg-selection-check" type="checkbox" value="checked" /></td>\r\n' + \
                        '<td class="msg-from-field">Socialray </td>\r\n' + \
                        '<td class="msg-subject"><span class="linkless" onclick="javascript:fx_flipElem(\'' + msg_row_id + '\', \'' + msg_row_xp_id + '\');">' + msg.subject + '</span>'
            if msg.body.strip():
                html += '<span class="dimmed-text"> ' + dataplus.getPreviewText(msg.body) + '</span>'
            html += '</td>\r\n' + \
                        '<td class="msg-datetime-field">' + dataplus.getShortRelativeDateTime(msg.sent_at) + '</td>' + \
                    '</tr></table>\r\n'
            html += '</div>\r\n'
            
            html += '<div id="' + msg_row_xp_id + '" class="email-msg-xp" style="display:none">\r\n'
            html += '<div style="font-size:12px;font-weight:bold">\r\nSocialray - ' + \
                        '<span class="linkless" onclick="javascript:fx_flipElem(\'' + msg_row_xp_id + '\', \'' + msg_row_id + '\');">'+ msg.subject + '</span>' + \
                    '</div>\r\n<div class="small-text" style="color:#999999;">' + \
                    dataplus.getRelativeDateTime(msg.sent_at) + '</div>\r\n' + msg.body + '\n' \
                    '<table><tr>\r\n' + \
                        '<td><input class="small-btn" type="button" name="hide-btn" value="Hide" onclick="javascript:fx_flipElem(\'' + msg_row_xp_id + '\', \'' + msg_row_id + '\');" /></td>' + \
                        '<td><input class="medium-btn" type="button" name="inbox-btn" value="Move to Inbox" onclick="javascript:moveToInbox(\'' + str(msg.id) + '\', \'' + msg_row_xp_id + '\');" /></td>' + \
                        '<td><input class="small-btn" type="button" name="delete-btn" value="Delete" onclick="javascript:deleteMessage(\'' + str(msg.id) + '\', \'' + msg_row_xp_id + '\');" /></td>' + \
                    '</tr></table>\r\n'
            html += '</div>\r\n'
            
        elif msg.message_type == 'TM':
            msg_row_id = 'email' + str(ctr)
            msg_row_xp_id = 'emailxp' + str(ctr)
            
            if msg.sender.account_type == 'U':
                sender_url = config.profiles_url + '/' + msg.sender.username
            elif msg.sender.account_type == 'R':
                rec = msg.sender.recruiter.all()[0]
                sender_url = config.recruiters_url + '/' + str(rec.id)

            html += '<div id="' + msg_row_id + '" class="email-msg-item">\r\n'
            html += '<table class="msg-item-table"><tr>\r\n' + \
                        '<td class="msg-selection" ><input id="' + chk_id + '" name="' + chk_id + '" class="msg-selection-check" type="checkbox" value="checked" /></td>\r\n' + \
                        '<td class="msg-from-field"><a href="' + sender_url + '">' + msg.sender.name + ' </a></td>\r\n' + \
                        '<td class="msg-subject"><span class="linkless" onclick="javascript:fx_flipElem(\'' + msg_row_id + '\', \'' + msg_row_xp_id + '\');">' + msg.subject + '</span><span class="dimmed-text"> ' + dataplus.getPreviewText(msg.body) + '</span></td>\r\n' + \
                        '<td class="msg-datetime-field">' + dataplus.getShortRelativeDateTime(msg.sent_at) + '</td>' + \
                    '</tr></table>\r\n'
            html += '</div>\r\n'
            
            html += '<div id="' + msg_row_xp_id + '" class="email-msg-xp" style="display:none">\r\n'
            html += '<div style="font-size:12px;font-weight:bold">\r\n' + \
                        '<a href="' + sender_url + '">' + msg.sender.name + '</a> - ' + \
                        '<span class="linkless" onclick="javascript:fx_flipElem(\'' + msg_row_xp_id + '\', \'' + msg_row_id + '\');">'+ msg.subject + '</span>' + \
                    '</div>\r\n<div class="small-text" style="color:#999999;">' + \
                    dataplus.getRelativeDateTime(msg.sent_at) + '</div>\r\n' + msg.body + '\n' \
                    '<table><tr>\r\n' + \
                        '<td><input class="small-btn" type="button" name="hide-btn" value="Hide" onclick="javascript:fx_flipElem(\'' + msg_row_xp_id + '\', \'' + msg_row_id + '\');" /></td>' + \
                        '<td><input class="medium-btn" type="button" name="inbox-btn" value="Move to Inbox" onclick="javascript:moveToInbox(\'' + str(msg.id) + '\', \'' + msg_row_xp_id + '\');" /></td>' + \
                        '<td><input class="small-btn" type="button" name="delete-btn" value="Delete" onclick="javascript:deleteMessage(\'' + str(msg.id) + '\', \'' + msg_row_xp_id + '\');" /></td>' + \
                    '</tr></table>\r\n'
            html += '</div>\r\n'            
                    
    html += '</div>\r\n'        
    html += '<div>'
    if paginator.count > 0:
        html += '<p><span style="color:#999999">Showing ' + str(page.start_index()) + '-' + str(page.end_index()) + \
            ' of ' + str(paginator.count) + ' </span></p>'

    html += '<table class="button-box"><tr>\r\n'
    if page_num != 1:
        html += '<td><input class="medium-btn" type="button" name="prev-btn" value="Prev" onclick="javascript:window.location.href=\'/mailbox/trashcan.htm?page=' + str(page_num-1) + '\';" /></td>\r\n'
    if page.has_next():
        html += '<td><input class="medium-btn" type="button" name="prev-btn" value="Next" onclick="javascript:window.location.href=\'/mailbox/trashcan.htm?page=' + str(page_num+1) + '\';" /></td>\r\n'
    html += '</tr></table>\r\n'

    html += '</div>'
    return html
コード例 #10
0
def getTopicBoxHtml(topic, can_post):
    topic_div_id = "topic_" + str(topic.id)  # full enclosure
    lastpost_div_id = "lastpost_" + str(topic.id)  # this shows the last post; ON by default
    xp_div_id = "xp_posts_" + str(topic.id)  # flips last post with last 5, OFF by default
    post_box_id = "post_box_" + str(topic.id)  # reply to the post right there

    last_posts = topic.posts.order_by("-posted_on")[:5]

    html = ""
    # topic box starts hear hear!
    html += '<div id="' + topic_div_id + '" class="community-topic-item">\r\n'

    # header....
    html += (
        '<div><span><strong><a href="/communities/'
        + str(topic.community.id)
        + "/topics/"
        + str(topic.id)
        + '">'
        + topic.title
        + "</a></strong> ("
        + str(topic.posts.count())
        + " posts)</span>\r\n"
    )
    html += (
        ' <span class="dimmed-text">started by <a href="'
        + config.profiles_url
        + "/"
        + topic.started_by.username
        + '">'
        + topic.started_by.name
        + "</a></span></div>\r\n"
    )

    if topic.posts.count() > 0:
        last_post = last_posts[0]
        # last post div - can be empty
        html += '<div id="' + lastpost_div_id + '">'
        html += (
            '<span class="small-text">Last Post ' + dataplus.getRelativeDateTime(last_post.posted_on) + "</span><br />"
        )
        html += dataplus.getPreviewText(last_post.text)
        html += (
            '<div class="small-text"><span class="linkless" onclick="fx_flipElem(\''
            + lastpost_div_id
            + "', '"
            + xp_div_id
            + "');\">Expand</span></div>\r\n"
        )
        html += "</div>"

        html += '<div id="' + xp_div_id + '" style="display:none;">\r\n'
        for post in last_posts:
            posted_by_url = config.profiles_url + "/" + post.posted_by.account.username
            html += (
                '<div class="community-post" style="padding:5px;border:solid;border-width: 1px;border-color:#dddddd;">\r\n'
                + '<table style="width:100%">\r\n'
                + "<tr>\r\n"
                + '<td style="width:60px;text-align:center;vertical-align:top;">\r\n'
                + '<a href="'
                + posted_by_url
                + '"><img src="'
                + dataplus.getStaticUrl(post.posted_by.image_size1_file_path)
                + '" alt="'
                + post.posted_by.name
                + '" /></a>\r\n'
                + "</td>\r\n"
                + '<td style="vertical-align:top;">\r\n'
                + '<div><a href="'
                + config.profiles_url
                + "/"
                + post.posted_by.username
                + '">\r\n'
                + post.posted_by.name
                + "</a> "
                + dataplus.getRelativeDateTime(post.posted_on)
                + "\r\n"
                + "</div>\r\n"
                + '<div class="community-post-text">'
                + dataplus.replaceHtmlLineBreaks(post.text)
                + "</div>\r\n"
                + "</td>\r\n"
                + "</tr>\r\n"
                + "</table>\r\n"
                + "</div>\r\n"
            )

        html += "<table><tr>\r\n"
        if can_post:
            html += (
                '<td><input class="small-btn" type="button" name="reply-btn" value="Reply" onclick="showTopicReplyBox(\''
                + post_box_id
                + "', '"
                + str(topic.id)
                + "', true, function(topicId, html){ reloadTopic(topicId, html); });\" /></td>"
            )
        html += (
            '<td><input class="small-btn" type="button" name="hide-btn" value="Hide" onclick="fx_flipElem(\''
            + xp_div_id
            + "', '"
            + lastpost_div_id
            + "');\" /></td>"
        )
        html += "</tr></table>\r\n"
        html += '<div id="' + post_box_id + '"></div>\r\n'
        html += "</div></div>"
    else:
        if can_post:
            html += (
                '<div><span class="linkless" onclick="showTopicReplyBox(\''
                + post_box_id
                + "', '"
                + str(topic.id)
                + "', true, function(topicId, html){ reloadTopic(topicId, html); });\" />Reply</span></div>\r\n"
            )
            html += '<div id="' + post_box_id + '"></div></div>\r\n'

    return html
コード例 #11
0
def handle(request):
    action_id = ''
    random_key = ''
    if dataplus.dictGetVal(request.REQUEST, 'inviteId'):
        action_id = 'inviteId'
        random_key = dataplus.dictGetVal(request.REQUEST, 'inviteId')
    elif dataplus.dictGetVal(request.REQUEST, 'commInviteId'):
        action_id = 'commInviteId'
        random_key = dataplus.dictGetVal(request.REQUEST, 'commInviteId')
    elif dataplus.dictGetVal(request.REQUEST, 'commFriendInviteId'):
        action_id = 'commFriendInviteId'
        random_key = dataplus.dictGetVal(request.REQUEST, 'commFriendInviteId')
    
    if not action_id:
        return HttpResponseRedirect('/')
    
    username = dataplus.dictGetVal(request.REQUEST, 'user')
    if username:        
        myself = siteaction.getLoggedInUser(request)
        if myself and myself.username == username:
            success, response = codejar_invites.processInvitations(myself, [action_id + '=' + random_key])
            return response
        else:
            siteaction.doLogout(request)
    
    if action_id == 'inviteId':
        friend_invite = dataplus.returnIfExists(models.FriendInvitation.objects.filter(invite_random_key=random_key))
    elif action_id == 'commInviteId':
        comm_invite = dataplus.returnIfExists(models.CommunityInvitation.objects.filter(invite_random_key=random_key))
    elif action_id == 'commFriendInviteId':
        friend_invite = dataplus.returnIfExists(models.FriendInvitation.objects.filter(invite_random_key=random_key))
        comm_invite = dataplus.returnIfExists(models.CommunityInvitation.objects.filter(invite_random_key=random_key))
    
    invited_by = None
    if action_id == 'inviteId' or action_id == 'commFriendInviteId':
        if friend_invite:
            invited_by = friend_invite.sent_by
            invited_by.image_url = dataplus.getStaticUrl(invited_by.image_size3_file_path)
        else:
            return HttpResponseRedirect('/login.htm')   ##TODO: Have to show a better response that invite doesn't exist
    
    if action_id == 'commInviteId' or action_id == 'commFriendInviteId':
        if comm_invite:
            invited_by = comm_invite.sent_by
            invited_by.image_url = dataplus.getStaticUrl(invited_by.image_size3_file_path)
            invited_comm = comm_invite.community
            invited_comm.image_url = dataplus.getStaticUrl(invited_comm.image_size3_file_path)
        else:
            return HttpResponseRedirect('/login.htm')   ##TODO: Have to show a better response that invite doesn't exist
    
    welcome_text = 'You have been invited to join Socialray by '+ invited_by.name + '. Socialray is a ' + \
        'Professional Networking site, where you can showcase your skills and expertise, ' + \
        'stay in touch with friends and colleagues, and a lot more. Come onboard, and find out!'
    
##    welcome_text = {'inviteId':'You were invited to join Socialray by ' + invited_by.name + '.',
##                    'commInviteId':'You were invited to join ' + invited_comm.name + ' by ' + invited_by.name + '.',
##                    'commFriendInviteId':'You were invited to join ' + invited_comm.name + ' by ' + invited_by.name + '.'}[action_id]
    
    login_url = '/login.htm?returnUrl=' + cgi.escape('/me/processinvites.htm?' + action_id + '=' + random_key)
    return siteaction.render_to_response('me/acceptinvite.htm', 
                                {'welcome_text':welcome_text,
                                'invited_by':invited_by,
                                'invited_comm':invited_comm,
                                'signup_url':'/me/signup.htm?' + action_id + '=' + random_key,
                                'login_url':login_url,
                                'invited_by_text':dataplus.getPreviewText(invited_by.hilite,500)})