Пример #1
0
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('&amp;','&'), 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')
Пример #2
0
def handle(request):
    import website.bigfoot.models as models
    zoomo_id = dataplus.dictGetVal(request.REQUEST, 'zid')
    hresume_contents = get_object_or_404(models.HResumeContents, zoomo_id=zoomo_id)
    
    if request.method == 'GET':      
        return render_to_response('resumitypublish.htm', 
            {'zid':zoomo_id})
    
    #Handles only post requests
    elif request.method == 'POST':
        html = hresume_contents.resume
        
        action = dataplus.dictGetSafeVal(request.REQUEST, 'action')
        user = None
        from website.bigfoot.utils import siteaction, codejar_resume, sessions_client, livewire_client
        if action == 'new_publish':
            username = dataplus.dictGetSafeVal(request.REQUEST, 'new_username')
            password1 = dataplus.dictGetSafeVal(request.REQUEST, 'password1')
            password2 = dataplus.dictGetSafeVal(request.REQUEST, 'password2')
            industry_category = hresume_contents.industry_category.name
            posted_data = simplejson.loads(base64.b64decode(hresume_contents.post_dict))
            experience = calculateExperience(posted_data)
            country = models.Country.objects.get(name=hresume_contents.country)
            
            full_name = (hresume_contents.fname + ' ' + hresume_contents.lname).strip()
            
            user = siteaction.createUser(username, full_name, password1, hresume_contents.email, country.code, industry_category, experience)
            session_id = sessions_client.query('addNewSession', [user.username])
        elif action == 'login_publish':
            username = dataplus.dictGetSafeVal(request.REQUEST, 'username')
            password = dataplus.dictGetSafeVal(request.REQUEST, 'password')
            success, session_id, url, info = siteaction.doAjaxLogin(username, password)
            if not success:
                return render_to_response('resumitypublish.htm', 
                    {'zid':zoomo_id,
                    'error_text': info})
            else:
                user = models.User.objects.get(username=username)
                
        html_body = html[html.index('<body>')+len('<body>'):html.index('</body>')]
        codejar_resume.saveResume(user, html_body)
        useraccount = user.account
        
        hresume_contents = models.HResumeContents.objects.get(zoomo_id=zoomo_id)
        hresume_contents.account = useraccount
        hresume_contents.save()

        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.getSocialrayStaticUrl(chat_settings.image_size1_file_path), dataplus.getSocialrayStaticUrl(chat_settings.image_size2_file_path), 
                dataplus.getSocialrayStaticUrl(chat_settings.image_size3_file_path)])
        
        return siteaction.redirectWithCookie('/me/', 'session_id', session_id)
Пример #3
0
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)