Beispiel #1
0
def create():
    form = JobForm()

    if form.validate_on_submit():
        job = populate_job(form)

        # Create a token to enable email reviewing.
        review_token = EmailReviewToken(job=job)

        db.session.add(review_token)
        db.session.add(job)
        db.session.commit()

        send_instructory_email(job)
        send_review_email(job, review_token.token)

        logger.info("Job ({}) was successfully created.".format(job.id))

        session['created_email'] = job.recruiter_email
        return redirect(url_for('views.created'))

    locations = get_location_context()
    tags = get_tag_context()

    return render_template('jobs/create_or_edit.html',
                           form=form,
                           locations=locations,
                           tags=tags,
                           prompt=CREATE_OR_UPDATE_PROMPT)
Beispiel #2
0
def preview():
    form = JobForm()

    if form.validate_on_submit():
        job = populate_job(form)
        return render_template('jobs/show_chromeless.html',
                               chromeless=True,
                               job=job)

    return render_template('jobs/preview_failed.html', form=form)
Beispiel #3
0
def populate_form(job):
    """Populates a `JobForm` object from a `Job` model.

    :param job: A `Job` instance.

    """
    location = job.location
    company = job.company

    related_data = {
        'location__id': location.id,
        'location__city': location.city,
        'location__country_code': location.country_code,
        'company__id': company.id,
        'company__name': company.name,
        'company__website': company.website_with_protocol
    }

    return JobForm(obj=job, **related_data)