Пример #1
0
def handle(request):
    if request.method == 'GET':
        return codejar.actions.render(request, 'forgotpassword.htm')
    elif request.method == 'POST':
        username = dataplus.dictGetSafeVal(request.REQUEST, 'email', '')
        account = dataplus.returnIfExists(
            models.Account.objects.filter(username=username))
        if account:
            account_detail = dataplus.returnIfExists(
                models.Recruiter.objects.filter(account=account))
            if not account_detail:
                account_detail = dataplus.returnIfExists(
                    models.User.objects.filter(account=account))

            token = models.Token.getNew(str(account.id), account.username,
                                        'ForgotPassword')
            params = {
                'account_key': token,
                'path': {
                    'FR': '/recruiters',
                    'PU': ''
                }[account.account_type]
            }

            mailer.sendPasswordResetLink(username, params)
            return HttpResponseRedirect('?flashId=pwd_change_emailed')
        else:
            errors = []
            errors.append(
                'Please provide the email that you used to register with us.')
            return codejar.actions.render(request, 'forgotpassword.htm',
                                          {'flash_alerts': errors})
Пример #2
0
def handle(request, account_type='user'):
    account, redirect = codejar.actions.handleSecurity(request, 'account')
    token_value = dataplus.dictGetSafeVal(request.REQUEST, 'key', '')

    url_prefix = ''
    if account_type == 'recruiters':
        url_prefix = 'recruiters/'

    if request.method == 'GET':
        return codejar.actions.render(
            request, url_prefix + 'changepassword.htm', {
                'key': token_value,
                'is_loggedin': ('true', '')[account is None]
            })

    elif request.method == 'POST':
        password = dataplus.dictGetSafeVal(request.REQUEST, 'password', '')
        password2 = dataplus.dictGetSafeVal(request.REQUEST, 'password2', '')
        errors = []
        if len(password) < 6:
            errors.append('Passwords should have minimum 6 characters.')
        elif not password == password2:
            errors.append('Passwords do not match.')

        if errors:
            flash_alerts = errors
            return codejar.actions.render(request,
                                          url_prefix + 'changepassword.htm',
                                          {'flash_alerts': flash_alerts})

        if not account:
            acct_id = string.atoi(models.Token.getOwner(token_value))
            account = dataplus.returnIfExists(
                models.Account.objects.filter(id=acct_id))

            if not account:
                return HttpResponseRedirect('/?flashId=malformed_url')

        account.setPassword(password)

        #Propaganda special
        if dataplus.dictGetVal(request.session, 'prop_login', False):
            request.session['prop_login'] = None
            prop_token = dataplus.returnIfExists(
                models.Token.objects.filter(owner=account.username,
                                            type='RecPropaganda'))
            if prop_token: prop_token.delete()

        if token_value:
            models.Token.remove(token_value)
            response = codejar.auth.login(
                request, account.username, password,
                'dashboard.htm?flashId=password_changed')
            return codejar.actions.addCookieToResponse(response, 'last_login',
                                                       account.username)
        else:
            return HttpResponseRedirect(
                'dashboard.htm?flashId=password_changed')
Пример #3
0
def handle(request):
    token_value = dataplus.dictGetSafeVal(request.REQUEST, 'key', '')
    if token_value:
        token = dataplus.returnIfExists(
            models.Token.objects.filter(value=token_value))

    if not token:
        return HttpResponseRedirect('/?flashId=malformed_url')

    if request.method == 'GET':
        return codejar.actions.render(request, 'recruiters/signup.htm',
                                      {'token': token})

    elif request.method == 'POST':
        name = dataplus.dictGetSafeVal(request.REQUEST, 'name', '').strip()
        email = dataplus.dictGetSafeVal(request.REQUEST, 'email', '').strip()
        password = dataplus.dictGetSafeVal(request.REQUEST, 'password',
                                           '').strip()
        password2 = dataplus.dictGetSafeVal(request.REQUEST, 'password2',
                                            '').strip()
        organization = dataplus.dictGetSafeVal(request.REQUEST, 'organization',
                                               '').strip()
        telephone = dataplus.dictGetSafeVal(request.REQUEST, 'telephone',
                                            '').strip()

        errors = validateSignup(name, email, password, password2, telephone,
                                organization)
        if not errors and dataplus.returnIfExists(
                models.Account.objects.filter(username=email)):
            errors.append('You already have an account with the same email.')

        if errors:
            return codejar.actions.render(
                request, 'recruiters/signup.htm', {
                    'name': name,
                    'email': email,
                    'organization': organization,
                    'telephone': telephone,
                    'flash_alerts': errors
                })

        email_verified = (email == token.tag)
        rec = addRecruiter(email, password, name, organization, telephone,
                           token, email_verified)
        subs = addDefaultSubscriptions(rec)

        #send activation email if sign up is not through an invite
        if not (email_verified):
            verify_token = models.Token.getNew(str(rec.account.id), email,
                                               'VerifyEmail')
            params = {'recruiter_key': verify_token}
            mailer.sendActivationLink(email, params)

        return codejar.auth.login(request, email, password)
Пример #4
0
def handle(request, account_type="user"):
    account, redirect = codejar.actions.handleSecurity(request, "account")
    token_value = dataplus.dictGetSafeVal(request.REQUEST, "key", "")

    url_prefix = ""
    if account_type == "recruiters":
        url_prefix = "recruiters/"

    if request.method == "GET":
        return codejar.actions.render(
            request,
            url_prefix + "changepassword.htm",
            {"key": token_value, "is_loggedin": ("true", "")[account is None]},
        )

    elif request.method == "POST":
        password = dataplus.dictGetSafeVal(request.REQUEST, "password", "")
        password2 = dataplus.dictGetSafeVal(request.REQUEST, "password2", "")
        errors = []
        if len(password) < 6:
            errors.append("Passwords should have minimum 6 characters.")
        elif not password == password2:
            errors.append("Passwords do not match.")

        if errors:
            flash_alerts = errors
            return codejar.actions.render(request, url_prefix + "changepassword.htm", {"flash_alerts": flash_alerts})

        if not account:
            acct_id = string.atoi(models.Token.getOwner(token_value))
            account = dataplus.returnIfExists(models.Account.objects.filter(id=acct_id))

            if not account:
                return HttpResponseRedirect("/?flashId=malformed_url")

        account.setPassword(password)

        # Propaganda special
        if dataplus.dictGetVal(request.session, "prop_login", False):
            request.session["prop_login"] = None
            prop_token = dataplus.returnIfExists(
                models.Token.objects.filter(owner=account.username, type="RecPropaganda")
            )
            if prop_token:
                prop_token.delete()

        if token_value:
            models.Token.remove(token_value)
            response = codejar.auth.login(request, account.username, password, "dashboard.htm?flashId=password_changed")
            return codejar.actions.addCookieToResponse(response, "last_login", account.username)
        else:
            return HttpResponseRedirect("dashboard.htm?flashId=password_changed")
Пример #5
0
def handle(request, format, user_id):
    if not request.user.is_authenticated():
        return HttpResponseRedirect('/admin/')

    user = dataplus.returnIfExists(models.User.objects.filter(id=user_id))
    if user: return codejar.user.downloadResume(user, format)
    else: return HttpResponse('User does not exist.')
Пример #6
0
def handle(request):
    user_key = dataplus.dictGetSafeVal(request.REQUEST, 'key', '')
    from_email = dataplus.dictGetVal(request.REQUEST, 'source', False,
                                     lambda x: x == 'email')
    user = dataplus.returnIfExists(models.User.objects.filter(key=user_key))
    if not user:
        return codejar.actions.render(
            request, 'info.htm', {
                'info_header':
                'Resume not found',
                'info_text':
                'This resume does not exist,<br /> or may have been deleted.'
            })

    if request.method == 'GET':
        return codejar.actions.render(request, 'resumeactive.htm', {
            'user_key': user_key,
            'from_email': from_email
        })
    elif request.method == 'POST':
        user.min_salary = dataplus.dictGetVal(request.REQUEST, 'minSalary', 0,
                                              string.atoi)
        user.pref_employer = dataplus.dictGetSafeVal(request.REQUEST,
                                                     'preferredEmployer', '')
        user.pref_location = dataplus.dictGetSafeVal(request.REQUEST,
                                                     'preferredLocations', '')
        user.save()
        return HttpResponseRedirect('done.html')
Пример #7
0
def handle(request):
    try:
        name = dataplus.dictGetSafeVal(request.REQUEST, 'name', '').strip()
        email = dataplus.dictGetSafeVal(request.REQUEST, 'email', '').strip()
        password = dataplus.dictGetSafeVal(request.REQUEST, 'password',
                                           '').strip()
        password2 = dataplus.dictGetSafeVal(request.REQUEST, 'password2',
                                            '').strip()
        telephone = dataplus.dictGetSafeVal(request.REQUEST, 'telephone',
                                            '').strip()

        errors = validateSignup(name, email, password, password2, telephone)
        if not errors and dataplus.returnIfExists(
                models.Account.objects.filter(username=email)):
            errors.append('You already have an account with the same email.')

        if errors:
            return codejar.ajaxian.getFailureResp(errors)
        else:
            user = codejar.user.addPremiumUser(name, email, password,
                                               telephone)
            pymt = models.Payment(
                account=user.account,
                amount=200,
                payment_mode='CCAvenue',
                description='Premium User account subscription')
            pymt.order_id = dataplus.getNewOrderId()
            pymt.save()
            request.session['Order_Id'] = pymt.order_id
            return codejar.ajaxian.getSuccessResp(pymt.order_id)
    except:
        return codejar.ajaxian.getFailureResp('')
Пример #8
0
def handle(request, format, user_id):
    if not request.user.is_authenticated(): return HttpResponseRedirect('/admin/')
    
    user = dataplus.returnIfExists(models.User.objects.filter(id=user_id))
    if user:    return codejar.user.downloadResume(user, format)
    else:       return HttpResponse('User does not exist.')
    
Пример #9
0
def handle(request):
    user_key = dataplus.dictGetSafeVal(request.REQUEST, 'key', '')
    user = dataplus.returnIfExists(
        models.User.objects.filter(key=user_key, account__account_type='FU'))
    if not user:
        return codejar.actions.render(
            request, 'info.htm', {
                'info_header':
                'Resume not found',
                'info_text':
                'This resume does not exist,<br /> or may have been deleted.'
            })

    if request.method == 'GET':
        return codejar.actions.render(request, 'removeresume.htm',
                                      {'user_key': user_key})
    elif request.method == 'POST':
        user.delete()
        return codejar.actions.render(
            request, 'info.htm', {
                'info_header':
                'Your resume has been removed',
                'info_text':
                """<p>To make your resume active again, just <a href="/">upload it</a><br />
                                                                            or send it as an attachment to <a href="mailto:[email protected]">[email protected]</a>.</p>
                                                                            <p>Thank you.</p>"""
            })
Пример #10
0
def handle(request):
    if request.method == 'GET':
        return codejar.actions.render(request, 'signup.htm')

    elif request.method == 'POST':
        name = dataplus.dictGetSafeVal(request.REQUEST, 'name', '').strip()
        email = dataplus.dictGetSafeVal(request.REQUEST, 'email', '').strip()
        password = dataplus.dictGetSafeVal(request.REQUEST, 'password',
                                           '').strip()
        password2 = dataplus.dictGetSafeVal(request.REQUEST, 'password2',
                                            '').strip()
        telephone = dataplus.dictGetSafeVal(request.REQUEST, 'telephone',
                                            '').strip()

        errors = validateSignup(name, email, password, password2, telephone)
        if not errors and dataplus.returnIfExists(
                models.Account.objects.filter(username=email)):
            errors.append('You already have an account with the same email.')

        if errors:
            return codejar.actions.render(
                request, 'signup.htm', {
                    'name': name,
                    'email': email,
                    'telephone': telephone,
                    'flash_alerts': errors
                })
        else:
            user = codejar.user.addPremiumUser(name, email, password,
                                               telephone)
            return codejar.auth.login(request, email, password)
Пример #11
0
def handle(request, account_type='user'):
    if request.method == 'GET':
        order_id = request.session['Order_Id']
        pymt = dataplus.returnIfExists(models.Payment.objects.filter(order_id=order_id))
        if pymt:
            account = dataplus.returnIfExists(models.Account.objects.filter(id=pymt.account.id))
            account.account_state = 'A'
            account.save()
            mailer.sendAnonUserWelcomeMail(account.username, {'username':account.username})
            request.session['username'] = account.username
            request.session['account_type'] = account.account_type
            request.session['account_state'] = account.account_state
            request.session['Order_Id'] = None
            return HttpResponseRedirect('/dashboard.htm?flashId=welcome_user')
        
        else:
            raise Http404
Пример #12
0
def getLoggedInAccount(request):
    username = dataplus.dictGetVal(request.session, 'username', '')
    if username:
        return dataplus.returnIfExists(models.Account.objects.filter(username=username))
        
    ##Propaganda Special - if request has a valid 'rec_token' in querysting, we can login them.
    token_str = dataplus.dictGetSafeVal(request.REQUEST, 'rec_token', '')
    if token_str:
        rec_username = models.Token.getOwner(token_str)
        if rec_username:
            account = dataplus.returnIfExists(models.Account.objects.filter(username=rec_username, account_type='FR'))
            if account:
                request.session['username'] = account.username
                request.session['account_type'] = account.account_type
                request.session['account_state'] = account.account_state
                request.session['prop_login'] = True
                return account
Пример #13
0
def handle(request, account_type='user'):
    if request.method == 'GET':
        order_id = request.session['Order_Id']
        pymt = dataplus.returnIfExists(
            models.Payment.objects.filter(order_id=order_id))
        if pymt:
            account = dataplus.returnIfExists(
                models.Account.objects.filter(id=pymt.account.id))
            account.account_state = 'A'
            account.save()
            mailer.sendAnonUserWelcomeMail(account.username,
                                           {'username': account.username})
            request.session['username'] = account.username
            request.session['account_type'] = account.account_type
            request.session['account_state'] = account.account_state
            request.session['Order_Id'] = None
            return HttpResponseRedirect('/dashboard.htm?flashId=welcome_user')

        else:
            raise Http404
Пример #14
0
def handle(request):
    if request.method == 'GET':
        return codejar.actions.render(request, 'forgotpassword.htm')
    elif request.method == 'POST':
        username = dataplus.dictGetSafeVal(request.REQUEST, 'email', '')
        account = dataplus.returnIfExists(models.Account.objects.filter(username=username))
        if account:
            account_detail = dataplus.returnIfExists(models.Recruiter.objects.filter(account=account))
            if not account_detail:
                account_detail = dataplus.returnIfExists(models.User.objects.filter(account=account))

            token = models.Token.getNew(str(account.id), account.username, 'ForgotPassword')
            params = {'account_key': token, 'path': {'FR':'/recruiters', 'PU':''}[account.account_type]}

            mailer.sendPasswordResetLink(username, params)
            return HttpResponseRedirect('?flashId=pwd_change_emailed')
        else:
            errors = []
            errors.append('Please provide the email that you used to register with us.')
            return codejar.actions.render(request, 'forgotpassword.htm',{'flash_alerts': errors})
Пример #15
0
def getLoggedInAccount(request):
    username = dataplus.dictGetVal(request.session, 'username', '')
    if username:
        return dataplus.returnIfExists(
            models.Account.objects.filter(username=username))

    ##Propaganda Special - if request has a valid 'rec_token' in querysting, we can login them.
    token_str = dataplus.dictGetSafeVal(request.REQUEST, 'rec_token', '')
    if token_str:
        rec_username = models.Token.getOwner(token_str)
        if rec_username:
            account = dataplus.returnIfExists(
                models.Account.objects.filter(username=rec_username,
                                              account_type='FR'))
            if account:
                request.session['username'] = account.username
                request.session['account_type'] = account.account_type
                request.session['account_state'] = account.account_state
                request.session['prop_login'] = True
                return account
Пример #16
0
def handle(request):
    try:
        rec = codejar.auth.getLoggedInRecruiter(request)
        if rec:
            user_key = dataplus.dictGetSafeVal(request.REQUEST, 'key', '')
            user = dataplus.returnIfExists(models.User.objects.filter(key=user_key))
            
            notifications.addNotification(user.id, 'ResumeRequest', data={'recruiter_id':rec.id})
            return codejar.ajaxian.getSuccessResp('')
        else:
            return codejar.ajaxian.getFailureResp('not_logged_in')
    except:
        return codejar.ajaxian.getFailureResp('')
Пример #17
0
def handle(request, account_type='user'):
    rec = None
    if account_type == 'user':
        user, redirect = codejar.actions.handleSecurity(request, 'user')
        if not user: return redirect
    elif account_type == 'recruiter':
        rec, redirect = codejar.actions.handleSecurity(request, 'recruiter')
        if not rec: return redirect
        user_key = dataplus.dictGetSafeVal(request.REQUEST, 'key', '')
        user = dataplus.returnIfExists(
            models.User.objects.filter(key=user_key))
        if not user:
            return codejar.actions.render(
                request, 'error.htm', {
                    'error_message':
                    'You have entered an invalid Url. Please check and try again.'
                })

    if request.method == 'GET':
        pref_summary = ''
        #12 Lakhs, Large Companies only, in Bangalore.
        if user.pref_designation and user.min_salary and user.pref_location and user.pref_employment:
            pref_summary = '%s in %s' % (user.pref_designation,
                                         html_options.getVerboseEmploymentType(
                                             user.pref_employment))
            if not user.pref_location == 'Anywhere':
                pref_summary += ', in ' + user.pref_location

        user.job_preferences = pref_summary
        if user.summary:
            user.summary_display = '<ul>\n' + reduce(
                lambda x, y: x + '<li>' + y + '</li>\n',
                user.summary.split('\n'), '') + '</ul>\n'

        user.min_salary_in_lakhs = user.min_salary / 100000

        if rec:
            sub_id = dataplus.dictGetVal(request.REQUEST, 'sub_id', 0,
                                         string.atoi)
            notifications.addNotification(str(user.id),
                                          'ProfViewed',
                                          data={
                                              'recruiter_id': rec.id,
                                              'subscription_id': sub_id
                                          })
        return codejar.actions.render(request, 'viewsummary.htm', {
            'user': user,
            'rec': rec
        })
    elif request.method == 'POST':
        pass
Пример #18
0
def handle(request):
    token_value = dataplus.dictGetSafeVal(request.REQUEST, 'key', '')
    if token_value:
        token = dataplus.returnIfExists(models.Token.objects.filter(value=token_value))
    
    if not token:
        return HttpResponseRedirect('/?flashId=malformed_url')
        
    if request.method == 'GET':
        return codejar.actions.render(request, 'recruiters/signup.htm' , {'token': token})

    elif request.method == 'POST':
        name = dataplus.dictGetSafeVal(request.REQUEST, 'name', '').strip()
        email = dataplus.dictGetSafeVal(request.REQUEST, 'email', '').strip()
        password = dataplus.dictGetSafeVal(request.REQUEST, 'password', '').strip()
        password2 = dataplus.dictGetSafeVal(request.REQUEST, 'password2', '').strip()
        organization = dataplus.dictGetSafeVal(request.REQUEST, 'organization', '').strip()
        telephone = dataplus.dictGetSafeVal(request.REQUEST, 'telephone', '').strip()

        errors = validateSignup(name, email, password, password2, telephone, organization)
        if not errors and dataplus.returnIfExists(models.Account.objects.filter(username=email)):
            errors.append('You already have an account with the same email.')

        if errors:
            return codejar.actions.render(request, 'recruiters/signup.htm', {'name':name, 'email':email, 'organization':organization,
                                                                'telephone':telephone, 'flash_alerts':errors})
        
        email_verified = (email == token.tag)
        rec = addRecruiter(email, password, name, organization, telephone, token, email_verified)
        subs = addDefaultSubscriptions(rec)
        
        #send activation email if sign up is not through an invite
        if not (email_verified):
            verify_token = models.Token.getNew(str(rec.account.id), email, 'VerifyEmail')
            params = {'recruiter_key':verify_token}
            mailer.sendActivationLink(email, params)
            
        return codejar.auth.login(request, email, password)
Пример #19
0
def handle(request):
    rec, redirect = codejar.actions.handleSecurity(request, 'recruiter')
    if not rec:     return redirect

    subscription_id = dataplus.dictGetSafeVal(request.REQUEST, 'subscriptionId')

    if request.method == 'GET':
        subscription = dataplus.returnIfExists(rec.subscriptions.filter(id=subscription_id))
        if (subscription):
            return codejar.actions.render(request, 'recruiters/subscribe.htm',
                {'subscription': subscription,
                 'experience_html':experienceHTML(subscription.experience),
                 'salary_html': salaryHTML(subscription.max_salary),
                 'location_html': locationHTML(subscription.location),
                 'subscriptionId': subscription_id})
        else:
            keywords = dataplus.dictGetSafeVal(request.REQUEST, 'keywords', '')
            experience = dataplus.dictGetVal(request.REQUEST, 'experience', '0', string.atoi)
            location = dataplus.dictGetSafeVal(request.REQUEST, 'location', '')
            max_salary = dataplus.dictGetVal(request.REQUEST, 'maxSalary', '0', string.atoi)
            return codejar.actions.render(request, 'recruiters/subscribe.htm',
                {'keywords':keywords,
                 'experience_html':experienceHTML(experience),
                 'salary_html': salaryHTML(max_salary),
                 'location_html': locationHTML(location)})

    elif request.method == 'POST':
        #Save the filter.
        def fillFormData(subs):
            subs.recruiter = rec
            subs.keywords = dataplus.dictGetSafeVal(request.REQUEST, 'keywords')
            subs.experience = dataplus.dictGetVal(request.REQUEST, 'experience', '0', string.atoi)
            subs.location = dataplus.dictGetSafeVal(request.REQUEST, 'location')
            subs.max_salary = dataplus.dictGetVal(request.REQUEST, 'maxSalary', '0', string.atoi)
            subs.job_title = dataplus.dictGetSafeVal(request.REQUEST, 'job_title')
            subs.job_company = dataplus.dictGetSafeVal(request.REQUEST, 'job_company')
            subs.job_description = dataplus.dictGetSafeVal(request.REQUEST, 'job_desc')

        if subscription_id:
            subscription = models.RecruiterSubscription.objects.get(id=subscription_id)
        else: #means new subscription
            subscription = models.RecruiterSubscription()
            subscription.min_count = 5
            subscription.industry = ''
            subscription.results_last_sent_on = datetime.datetime(1981, 1, 9) #Jes' bday - default min datetime

        fillFormData(subscription)
        subscription.save()

        return HttpResponseRedirect('/recruiters/dashboard.htm')
Пример #20
0
def handle(request, format, user_key):
    rec, redirect = codejar.actions.handleSecurity(request, 'recruiter')
    if not rec:
        rec_key = dataplus.dictGetSafeVal(request.REQUEST, 'key', '')
        if rec_key: rec = dataplus.returnIfExists(models.Recruiter.object.filter(key=rec_key))        
    if not rec: return redirect
    
    user = get_object_or_404(models.User, key=user_key)    
    if not format in ('doc', 'html'): 
		format = 'doc'
    
    sub_id = dataplus.dictGetVal(request.REQUEST, 'sub_id', 0)
    notifications.addNotification(str(user.id), 'ProfViewed', data={'recruiter_id': rec.id, 'subscription_id':sub_id})
    
    return codejar.user.downloadResume(user, format)
Пример #21
0
def handle(request):
    try:
        rec = codejar.auth.getLoggedInRecruiter(request)
        if rec:
            token = dataplus.returnIfExists(models.Token.objects.filter(owner=rec.email, type="VerifyEmail"))
            if not token:
                token = models.Token.getNew(rec.account.id, rec.email, "VerifyEmail")
            else:
                token = token.value
            params = {"recruiter_key": token}
            mailer.sendActivationLink(rec.email, params)
            return codejar.ajaxian.getSuccessResp(True)
        else:
            return codejar.ajaxian.getFailureResp("not_logged_in")
    except:
        return codejar.ajaxian.getFailureResp("")
Пример #22
0
def handle(request):
    user_key = dataplus.dictGetSafeVal(request.REQUEST, 'key', '')
    from_email = dataplus.dictGetVal(request.REQUEST, 'source', False, lambda x: x == 'email')
    user = dataplus.returnIfExists(models.User.objects.filter(key=user_key))
    if not user:
        return codejar.actions.render(request, 'info.htm', {'info_header':'Resume not found',
                                                            'info_text':'This resume does not exist,<br /> or may have been deleted.'})
    
    if request.method == 'GET':
        return codejar.actions.render(request, 'resumeactive.htm', {'user_key':user_key,'from_email':from_email})
    elif request.method == 'POST':
        user.min_salary = dataplus.dictGetVal(request.REQUEST, 'minSalary', 0, string.atoi)
        user.pref_employer = dataplus.dictGetSafeVal(request.REQUEST, 'preferredEmployer', '')
        user.pref_location = dataplus.dictGetSafeVal(request.REQUEST, 'preferredLocations', '')
        user.save()
        return HttpResponseRedirect('done.html')
Пример #23
0
def handle(request):
    user_key = dataplus.dictGetSafeVal(request.REQUEST, 'key', '')
    user = dataplus.returnIfExists(models.User.objects.filter(key=user_key, account__account_type='FU'))
    if not user:
        return codejar.actions.render(request, 'info.htm', {'info_header':'Resume not found',
                                                            'info_text':'This resume does not exist,<br /> or may have been deleted.'})
    
    if request.method == 'GET':
        return codejar.actions.render(request, 'removeresume.htm', {'user_key':user_key})
    elif request.method == 'POST':
        user.delete()
        return codejar.actions.render(request, 'info.htm', {'info_header':'Your resume has been removed',
                                                            'info_text':"""<p>To make your resume active again, just <a href="/">upload it</a><br />
                                                                            or send it as an attachment to <a href="mailto:[email protected]">[email protected]</a>.</p>
                                                                            <p>Thank you.</p>"""})
        
Пример #24
0
def handle(request):
    try:
        rec = codejar.auth.getLoggedInRecruiter(request)
        if rec:
            user_key = dataplus.dictGetSafeVal(request.REQUEST, 'key', '')
            user = dataplus.returnIfExists(
                models.User.objects.filter(key=user_key))

            notifications.addNotification(user.id,
                                          'ResumeRequest',
                                          data={'recruiter_id': rec.id})
            return codejar.ajaxian.getSuccessResp('')
        else:
            return codejar.ajaxian.getFailureResp('not_logged_in')
    except:
        return codejar.ajaxian.getFailureResp('')
Пример #25
0
def handle(request):
    if request.method == 'GET':
        key = dataplus.dictGetSafeVal(request.REQUEST, 'key', 'NotFound')
        rec_acct_id = models.Token.getOwner(key)
        rec = dataplus.returnIfExists(models.Recruiter.objects.filter(account__id=rec_acct_id))
        if not rec: return HttpResponseRedirect('/?flashId=malformed_url')
        
        rec.account.email_verified = True
        rec.account.save()

        models.Token.remove(key)
        
        return codejar.actions.render(request, 'recruiters/emailverified.htm')
        
    elif request.method == 'POST':
        pass
Пример #26
0
def handle(request):
    rec, redirect = codejar.actions.handleSecurity(request, 'recruiter')
    if not rec:	return redirect

    page = dataplus.dictGetVal(request.REQUEST, 'page', 0, string.atoi)
    subscr_id = dataplus.dictGetVal(request.REQUEST, 'sub_id', 0, string.atoi)
    keywords = dataplus.dictGetSafeVal(request.REQUEST, 'keywords', '')
    search_tuple = dataplus.dictGetSafeVal(request.REQUEST, 'searchTuple', '')
    search_dict = {}
    min_datetime = datetime.datetime(1981, 1, 9)    #Jes B'day
    response = None
    search_desc = ''
    if subscr_id:    
        subscr = dataplus.returnIfExists(models.RecruiterSubscription.objects.filter( id=subscr_id))
        if not (subscr and subscr.recruiter == rec):	raise Http404
        search_dict = {'keywords':subscr.keywords, 'experience':subscr.experience, 'location':subscr.location,
                       'max_salary':subscr.max_salary, 'limit_time':subscr.results_last_sent_on}
    elif keywords:
        experience = dataplus.dictGetVal(request.REQUEST, 'experience', 0, string.atoi)
        location = dataplus.dictGetSafeVal(request.REQUEST, 'location', 'Any')
        max_salary = dataplus.dictGetVal(request.REQUEST, 'maxSalary', 0, string.atoi)
        search_tuple = base64.b64encode(cPickle.dumps((keywords, experience, location, max_salary)))
        search_dict = {'keywords':keywords.strip('\r'), 'experience':experience, 'location':location.strip('\r'),
                       'max_salary':max_salary, 'limit_time':min_datetime}
        models.RecruiterData.addToRecentSearches(rec, search_dict)
    elif search_tuple:
        search_keywords, experience, location, max_salary = cPickle.loads(base64.b64decode(search_tuple))
        search_dict = {'keywords':search_keywords, 'experience':experience, 'location':location,
                       'max_salary':max_salary, 'limit_time':min_datetime}
    else:
        raise Http404
    
    response = search_helper.matchResumes(search_dict['keywords'], search_dict['experience'], search_dict['location'], search_dict['max_salary'], search_dict['limit_time'], start=page * page_size, rows=page_size)
    user_list = response.results
    num_pages = 0
    if (len(user_list) > 0):
    	num_pages = ((string.atoi(response.numFound )-1) / page_size) + 1
    
    return codejar.actions.render(request, 'recruiters/searchresults.htm', {'subscription_id':subscr_id,
                              'search_tuple': search_tuple,
                              'search_url': urllib.urlencode(search_dict),
                              'users': addFormatting(user_list, page),
                              'search_desc': getSearchDisplay(search_dict),
                              'links_html': getLinksHtml(num_pages, page, user_list),
                              'num_results':response.numFound,
                              'date':datetime.datetime.utcnow().strftime('%B %e, %Y')
                              })
Пример #27
0
def handle(request):
    if request.method == 'GET':
        key = dataplus.dictGetSafeVal(request.REQUEST, 'key', 'NotFound')
        rec_acct_id = models.Token.getOwner(key)
        rec = dataplus.returnIfExists(
            models.Recruiter.objects.filter(account__id=rec_acct_id))
        if not rec: return HttpResponseRedirect('/?flashId=malformed_url')

        rec.account.email_verified = True
        rec.account.save()

        models.Token.remove(key)

        return codejar.actions.render(request, 'recruiters/emailverified.htm')

    elif request.method == 'POST':
        pass
Пример #28
0
def login(request, username, password, success_url=''):
    account = dataplus.returnIfExists(models.Account.objects.filter(username=username, password=dataplus.hash(password)))
    redirect_url = '/login.htm?flashId=login_failed'
    if account and account.account_type in ['FR','PU']:
        request.session['username'] = account.username
        request.session['account_type'] = account.account_type
        request.session['account_state'] = account.account_state
        
        if success_url:
            redirect_url = success_url
        elif request.GET.get('redir',''):
            redirect_url = request.GET.get('redir','').replace('__amp__', '&')
        else:
            redirect_url = {'FR': '/recruiters/',
                            'PU':'/dashboard.htm'}[account.account_type]
                        
    return HttpResponseRedirect(redirect_url)
Пример #29
0
def handle(request, account_type="user"):
    rec = None
    if account_type == "user":
        user, redirect = codejar.actions.handleSecurity(request, "user")
        if not user:
            return redirect
    elif account_type == "recruiter":
        rec, redirect = codejar.actions.handleSecurity(request, "recruiter")
        if not rec:
            return redirect
        user_key = dataplus.dictGetSafeVal(request.REQUEST, "key", "")
        user = dataplus.returnIfExists(models.User.objects.filter(key=user_key))
        if not user:
            return codejar.actions.render(
                request, "error.htm", {"error_message": "You have entered an invalid Url. Please check and try again."}
            )

    if request.method == "GET":
        pref_summary = ""
        # 12 Lakhs, Large Companies only, in Bangalore.
        if user.pref_designation and user.min_salary and user.pref_location and user.pref_employment:
            pref_summary = "%s in %s" % (
                user.pref_designation,
                html_options.getVerboseEmploymentType(user.pref_employment),
            )
            if not user.pref_location == "Anywhere":
                pref_summary += ", in " + user.pref_location

        user.job_preferences = pref_summary
        if user.summary:
            user.summary_display = (
                "<ul>\n" + reduce(lambda x, y: x + "<li>" + y + "</li>\n", user.summary.split("\n"), "") + "</ul>\n"
            )

        user.min_salary_in_lakhs = user.min_salary / 100000

        if rec:
            sub_id = dataplus.dictGetVal(request.REQUEST, "sub_id", 0, string.atoi)
            notifications.addNotification(
                str(user.id), "ProfViewed", data={"recruiter_id": rec.id, "subscription_id": sub_id}
            )
        return codejar.actions.render(request, "viewsummary.htm", {"user": user, "rec": rec})
    elif request.method == "POST":
        pass
Пример #30
0
def handle(request, user_key):

	if request.method == 'GET':
		rec, redirect = codejar.actions.handleSecurity(request, 'recruiter')
		if not rec:
			rec_key = dataplus.dictGetSafeVal(request.REQUEST, 'key', '')
			if rec_key: rec = dataplus.returnIfExists(models.Recruiter.object.filter(key=rec_key))
			if not rec: return redirect

		user = get_object_or_404(models.User, key=user_key)

		sub_id = dataplus.dictGetVal(request.REQUEST, 'sub_id', 0)
		notifications.addNotification(str(user.id), 'ProfViewed', data={'recruiter_id': rec.id, 'subscription_id':sub_id})

		return codejar.user.downloadResume(user, 'doc')

	else:
		#this shouldnt be happening
		return HttpResponseRedirect('/')
Пример #31
0
def handle(request):    
    if request.method == 'GET':
        return codejar.actions.render(request, 'signup.htm')
        
    elif request.method == 'POST':
        name = dataplus.dictGetSafeVal(request.REQUEST, 'name', '').strip()
        email = dataplus.dictGetSafeVal(request.REQUEST, 'email', '').strip()
        password = dataplus.dictGetSafeVal(request.REQUEST, 'password', '').strip()
        password2 = dataplus.dictGetSafeVal(request.REQUEST, 'password2', '').strip()
        telephone = dataplus.dictGetSafeVal(request.REQUEST, 'telephone', '').strip()
        
        errors = validateSignup(name, email, password, password2, telephone)
        if not errors and dataplus.returnIfExists(models.Account.objects.filter(username=email)):
            errors.append('You already have an account with the same email.')
            
        if errors:
            return codejar.actions.render(request, 'signup.htm', {'name':name, 'email':email, 'telephone':telephone,
                                                                'flash_alerts':errors})
        else:
            user = codejar.user.addPremiumUser(name, email, password, telephone)
            return codejar.auth.login(request, email, password)
Пример #32
0
def login(request, username, password, success_url=''):
    account = dataplus.returnIfExists(
        models.Account.objects.filter(username=username,
                                      password=dataplus.hash(password)))
    redirect_url = '/login.htm?flashId=login_failed'
    if account and account.account_type in ['FR', 'PU']:
        request.session['username'] = account.username
        request.session['account_type'] = account.account_type
        request.session['account_state'] = account.account_state

        if success_url:
            redirect_url = success_url
        elif request.GET.get('redir', ''):
            redirect_url = request.GET.get('redir', '').replace('__amp__', '&')
        else:
            redirect_url = {
                'FR': '/recruiters/',
                'PU': '/dashboard.htm'
            }[account.account_type]

    return HttpResponseRedirect(redirect_url)
Пример #33
0
def handle(request):
    user, redirect = codejar.actions.handleSecurity(request, 'user')
    if not user:	return redirect
    
    if request.method == 'GET':
        #YYYYMMDD
        report_date = dataplus.dictGetVal(request.REQUEST, 'date', None, lambda x: datetime.datetime.strptime(x, '%Y%m%d'))
        if not report_date:
            return HttpResponseRedirect('/?flashId=malformed_url')
        
        notification = dataplus.returnIfExists(models.Notification.objects.filter(key=str(user.id), type='UserReport', activity_time__year=report_date.year,
                                                                             activity_time__month = report_date.month,
                                                                             activity_time__day = report_date.day))
        if not notification:
            return HttpResponseRedirect('/?flashId=malformed_url')
        
        context = cPickle.loads(str(notification.text))
        return codejar.actions.render(request, 'resumesentreport.htm',
                                      {'recruiter_infos':context['recruiter_infos'],
                                       'num_of_sends': context['num_of_sends'],
                                       'date': report_date})
    elif request.method == 'POST':
        pass
Пример #34
0
 def getOwner(cls, token_value):
     token = dataplus.returnIfExists(Token.objects.filter(value=token_value))
     if token: return token.owner
Пример #35
0
 def remove(cls, token_value):
     token = dataplus.returnIfExists(Token.objects.filter(value=token_value))
     if token : token.delete()