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)
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)
def edit(job_id, token): job = db.session.query(Job).filter_by(admin_token=token).first() if not (job and job_id == job.id): abort(404) form = populate_form(job) if form.validate_on_submit(): job = populate_job(form, job=job) # An edited job is pending review so it needs to be unpublished. job.published = False # Create a token to enable email reviewing. review_token = EmailReviewToken(job=job) db.session.add(review_token) db.session.commit() send_review_email(job, review_token.token) logger.info("Job ({}) was successfully edited.".format(job.id)) session['edited_email'] = job.recruiter_email return redirect(url_for('views.edited')) locations = get_location_context() tags = get_tag_context() return render_template('jobs/create_or_edit.html', form=form, token=token, locations=locations, tags=tags, prompt=CREATE_OR_UPDATE_PROMPT)