Example #1
0
def c_login_form():
    try:
        email = unicode(Markup(request.form['email']).striptags())
        if len(email) < 10 or len(email) > 120:
            return render_template("companies/login.html",
                                   alert="Bad email size.",
                                   alert_type="warning")
    except Exception as e:
        return render_template("companies/login.html",
                               alert="Bad email.",
                               alert_type="warning")
    try:
        password = unicode(Markup(request.form['pwd']).striptags())
        if len(password) < 10 or len(password) > 120:
            return render_template("companies/login.html",
                                   alert="Bad password size.",
                                   alert_type="warning")
    except Exception as e:
        return render_template("companies/login.html",
                               alert="Bad password.",
                               alert_type="warning")
    from pojo import CompanyAuthBean
    bean = CompanyAuthBean()
    if bean.login(email, password):
        from pojo import CompanyJobBean
        bean = CompanyJobBean(session["X-Auth-Token"])
        jobs = bean.all()
        return render_template("companies/dashboard.html", jobs=jobs)
    else:
        return render_template("companies/login.html",
                               alert="Bad credentials.",
                               alert_type="warning")
Example #2
0
def c_dashboard():
    from pojo import CompanyAuthBean
    bean = CompanyAuthBean()
    if not bean.verify_token(session["X-Auth-Token"]):
        session.clear()
        return render_template("companies/index.html")

    from pojo import CompanyJobBean
    bean = CompanyJobBean(session["X-Auth-Token"])
    jobs = bean.all()
    return render_template("companies/dashboard.html", jobs=jobs)
Example #3
0
def c_job_add():
    from pojo import CompanyAuthBean
    bean = CompanyAuthBean()
    if not bean.verify_token(session["X-Auth-Token"]):
        session.clear()
        return render_template("companies/index.html")

    # verify input

    try:
        title = unicode(Markup(request.form['title']).striptags())
        if len(title) < 10 or len(title) > 120:
            return render_template("companies/job_form.html",
                                   alert="Bad title size.",
                                   alert_type="warning")
    except Exception as e:
        return render_template("companies/job_form.html",
                               alert="Bad title.",
                               alert_type="warning")
    try:
        description = unicode(Markup(request.form['description']).striptags())
        if len(description) < 10 or len(description) > 1000:
            return render_template("companies/job_form.html",
                                   alert="Bad description size.",
                                   alert_type="warning")
    except Exception as e:
        return render_template("companies/job_form.html",
                               alert="Bad description.",
                               alert_type="warning")

    try:
        salary = unicode(Markup(request.form['salary']).striptags())
        salary = int(salary)
        if salary <= 0:
            return render_template("companies/job_form.html",
                                   alert="Bad salary size.",
                                   alert_type="warning")
    except Exception as e:
        return render_template("companies/job_form.html",
                               alert="Bad salary.",
                               alert_type="warning")

    try:
        location = unicode(Markup(request.form['location']).striptags())
        if len(location) < 10 or len(location) > 120:
            return render_template("companies/job_form.html",
                                   alert="Bad location size.",
                                   alert_type="warning")
    except Exception as e:
        return render_template("companies/job_form.html",
                               alert="Bad location.",
                               alert_type="warning")

    try:
        remote = unicode(Markup(request.form['remote']).striptags())
        remote = True
    except Exception as e:
        remote = False

    try:
        internship = unicode(Markup(request.form['internship']).striptags())
        internship = True
    except Exception as e:
        internship = False

    from pojo import CompanyJobBean
    bean = CompanyJobBean(session["X-Auth-Token"])
    if bean.add(title, description, salary, location, remote, internship):
        jobs = bean.all()
        return render_template("companies/dashboard.html",
                               jobs=jobs,
                               alert="Job published successfully.",
                               alert_type="success")
    else:
        return render_template("companies/dashboard.html",
                               alert="Please try again.",
                               alert_type="warning")