Esempio n. 1
0
def handle(request): 
    try:
        account = siteaction.getLoggedInAccount(request)
        if not account:
            return ajaxian.getFailureResp('not_logged_in')
        
        status = dataplus.dictGetSafeVal(request.REQUEST,'status','everyone')
        cs = models.ChatSettings.objects.get(account=account)
        cs.online_status = status
        cs.save()
        
        session_id = request.COOKIES['session_id']
        siteaction.updateLivewireData(session_id, account)
        
        return ajaxian.getSuccessResp('')
    except:
        return ajaxian.getFailureResp('unknown')
Esempio n. 2
0
def getRelationships(request, receivers):   
    receivers_infos = []
    my_account = siteaction.getLoggedInAccount(request)
    if not my_account:
        for username in receivers:
            receivers_infos.append(dataplus.listToString([username,'anyone']))
    
    elif my_account.account_type == 'U':
        friends = models.User.objects.filter(friends__username=my_account.username).values('username')
        friends_usernames = [dict.values()[0] for dict in friends]
        for username in receivers:
            if username == my_account.username:
                receivers_infos.append(dataplus.listToString([username,'self']))
            elif username in friends_usernames:
                receivers_infos.append(dataplus.listToString([username,'friend']))
            else:
                receivers_infos.append(dataplus.listToString([username,'anyone']))
        
    elif my_account.account_type == 'R':
        for username in receivers:
            receivers_infos.append(dataplus.listToString([username,'recruiter']))
    return receivers_infos
Esempio n. 3
0
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')
Esempio n. 4
0
def handle(request):  
    account = siteaction.getLoggedInAccount(request)
    if not account:
        return HttpResponseRedirect('/login.htm')
    
    #TODO: notify user about success, success_page will change
    logged_in_type = siteaction.getLoggedInAccountType(request)
    if logged_in_type == 'U':
        entry_page = 'me/changeemail.htm'
        success_page = '/me/editsettings.htm?flashId=email_chnged'
        error_page = 'me/showmessage.htm'
        myself = siteaction.getLoggedInUser(request)
    elif logged_in_type == 'R':
        entry_page = 'recruiters/changeemail.htm'    
        success_page = '/recruiters/'
        error_page = 'recruiters/showmessage.htm'
        myself = siteaction.getLoggedInRecruiter(request)
    
    if request.method == 'GET':
        return siteaction.render_to_response(entry_page, {'myself':myself})

    elif request.method == 'POST':
        #Password Check
        if (siteaction.validatePassword(myself.account.id, dataplus.dictGetVal(request.REQUEST, 'password'))):
            
            result, errMsg = codejar_validation.validateEmail(dataplus.dictGetVal(request.REQUEST,'email'))
            if not result:
                return siteaction.render_to_response(error_page, {'myself':myself, 'msg_heading':'Error', 'msg_html':'Invalid user input.'})
            
            email_address = dataplus.dictGetSafeVal(request.REQUEST, 'email')
            account.email = email_address
            account.save()
            myself.email = email_address
            myself.save()
            return HttpResponseRedirect(success_page)
        else:
            return siteaction.render_to_response(entry_page, 
                {'error_html': '<p class="error-note">Password was incorrect. Try again.</p>'})
Esempio n. 5
0
def handle(request):
    myself = siteaction.getLoggedInAccount(request)
    if not myself:
        return HttpResponseRedirect('/login.htm')

    #TODO: notify user about success, success_page will change
    logged_in_type = siteaction.getLoggedInAccountType(request)
    if logged_in_type == 'U':
        pwd_page = 'me/changepassword.htm'
        success_page = '/me/editsettings.htm?flashId=pwd_chnged'
    elif logged_in_type == 'R':
        pwd_page = 'recruiters/changepassword.htm'    
        success_page = '/recruiters/'
    
    if request.method == 'GET':
        return siteaction.render_to_response(pwd_page, {'myself':myself})

    elif request.method == 'POST':

        #Password length >= 6 and <=12
        valid, invalid_msg = dataplus.isLengthValid(dataplus.dictGetVal(request.REQUEST, 'password1'), 6, 12, 'Password')
        if not valid:
            return siteaction.render_to_response(pwd_page, 
                {'error_html': '<p class="error-note">' + invalid_msg + '</p>'})   
        
        #Passwords should match
        if dataplus.dictGetVal(request.REQUEST, 'password1') != dataplus.dictGetVal(request.REQUEST, 'password2'):
            return siteaction.render_to_response(pwd_page, 
                {'error_html': '<p class="error-note">Passwords do not match.</p>'})
        
        #Is the Old Password Check
        if (siteaction.validatePassword(myself.id, dataplus.dictGetVal(request.REQUEST, 'oldpassword'))):
            myself.password = dataplus.hash(dataplus.dictGetVal(request.REQUEST, 'password1'))
            myself.save()            
            return HttpResponseRedirect(success_page)
        else:
            return siteaction.render_to_response(pwd_page, 
                {'error_html': '<p class="error-note">Old password was incorrect. Try again.</p>'})