Esempio n. 1
0
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):
    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')
Esempio n. 3
0
def getMediaTableHtml(user):
    media_links = models.MediaLink.objects.filter(user=user)
    media_table_html = ''
    ctr = 0
    for media in media_links:
        if media.media_host == 'youtube':
            ctr += 1
            media_table_html += '<tr>'
            media_table_html += '<td class="video-url"><a href="' + media.url + '"><span class="small-text">' + media.url + '</span></a></td>'
            media_table_html += '<td class="show-in-profile">' + dataplus.conditionalValue(lambda: media.is_featured==True, 'Yes', 'No') + '</td>'
            media_table_html += '<td><input type="button" class="small-btn" value="Delete" onclick="javascript:deleteMedia(' + str(media.id) + ')" /></td>'
            media_table_html += '</tr>'
    
    return media_table_html
def handle(request):
    myself = siteaction.getLoggedInUser(request)
    if not myself:
        return HttpResponseRedirect('/login.htm')
    
    user_settings = models.UserSettings.objects.get(user=myself)
    chat_settings = models.ChatSettings.objects.get(account=myself.account)
        
    if request.method == 'GET':
        action_result = ''
        if dataplus.dictGetVal(request.REQUEST, 'flashId'):
            action_result = dataplus.dictGetVal(statix.action_messages, dataplus.dictGetVal(request.REQUEST, 'flashId'), '')
        
        online_status_select_html = hotmetal.elemSelect([('Everyone', 'everyone'), ('Friends only', 'friends'), ('Nobody', 'nobody')], [],
            lambda x:x[0], lambda x:x[1], chat_settings.online_status, 'name="online_status" id="online_status" style="width:160px;"')
        
        invite_preference_select_html = hotmetal.elemSelect([('Everyone', 'everyone'), ('Friends only', 'friends'), ('Nobody', 'nobody')], [],
            lambda x:x[0], lambda x:x[1], chat_settings.invite_preference, 'name="invite_preference" id="invite_preference" style="width:160px;"')
            
        ignored_usernames = chat_settings.ignore_list.split(',')
        ignored_accounts = []
        for username in ignored_usernames:
            try:
                ignored_accounts.append(models.Account.objects.get(username=username))
            except:
                pass
        
        ignore_list_select_html = hotmetal.elemSelect([], ignored_accounts,
            lambda x:x.name + ' (' + x.username + ')', lambda x:x.username, '', 'name="ignore_list_select" id="ignore_list_select" size="8" multiple="multiple" style="width:240px;"')
            
        skype_username = ''
        yahoo_username = ''
        for msnger in models.WebMessenger.objects.filter(account=myself.account):
            if msnger.provider == 'skype':  skype_username = msnger.username
            elif msnger.provider == 'yahoo':  yahoo_username = msnger.username
        
        return siteaction.render_to_response('me/editconnectsettings.htm',
        {'online_status_select_html': online_status_select_html,
         'custom_message': chat_settings.custom_message,
         'invite_preference_select_html': invite_preference_select_html, 
         'ignore_list_select_html': ignore_list_select_html, 
         'phone': dataplus.replaceNull(myself.phone, ''),
         'enable_voip_dial': dataplus.conditionalValue(lambda: user_settings.enable_voip_dial == True, 'checked="checked"', ''),
         'skype_username':skype_username,
         'yahoo_username':yahoo_username,
         'blog_url': dataplus.replaceNull(myself.blog_url, ''),
         'action_result':action_result,
         'myself': myself})
        
    elif request.method == 'POST':            
        action = dataplus.dictGetVal(request.REQUEST, 'action')
        if action == 'save_chat_settings':
            chat_settings.online_status = dataplus.dictGetSafeVal(request.REQUEST, 'online_status')
            chat_settings.custom_message = dataplus.dictGetSafeVal(request.REQUEST, 'custom_message')
            chat_settings.invite_preference = dataplus.dictGetSafeVal(request.REQUEST, 'invite_preference')
            chat_settings.ignore_list = dataplus.dictGetSafeVal(request.REQUEST, 'ignore_list')
            chat_settings.save()
        
            session_id = request.COOKIES['session_id']
            siteaction.updateLivewireData(session_id, myself.account)
        
        elif action == 'save_telephone_settings':
            myself.phone = dataplus.dictGetSafeVal(request.REQUEST, 'phone')
            myself.save()
            user_settings.enable_voip_dial = dataplus.dictGetVal(request.REQUEST, 'enable_voip_dial', False, lambda x:True)
            user_settings.save()
        
        elif action == 'save_messengers_settings':
            for msnger in models.WebMessenger.objects.filter(account=myself.account):
                msnger.delete()
                
            if dataplus.dictGetSafeVal(request.REQUEST, 'skype_username'):
                skype_profile = models.WebMessenger(provider='skype')
                skype_profile.account=myself.account
                skype_profile.username = dataplus.dictGetSafeVal(request.REQUEST, 'skype_username')
                skype_profile.save()
            
            if dataplus.dictGetSafeVal(request.REQUEST, 'yahoo_username'):
                #remove '@yahoo.com' if its there
                yahoo_username = dataplus.dictGetSafeVal(request.REQUEST, 'yahoo_username').partition('@')[0]
                yahoo_profile = models.WebMessenger(provider='yahoo')
                yahoo_profile.account=myself.account
                yahoo_profile.username = yahoo_username
                yahoo_profile.save()
        
        elif action == 'save_blog_settings':
            myself.blog_url = dataplus.dictGetSafeVal(request.REQUEST, 'blog_url')
            if myself.blog_url and not myself.blog_url.lower().startswith('http://'):
                myself.blog_url = 'http://' + myself.blog_url
            myself.save()
            
        return HttpResponseRedirect('/me/editconnectsettings.htm?flashId=connectset_saved')