Example #1
0
def admin_publish_job(company_id):
    if current_user.id != company_id:
        abort(404)
    form = JobForm()
    if form.validate_on_submit():
        form.create_job(current_user)
        flash('职位创建成功', 'success')
        return redirect(url_for('company.admin_index', company_id=current_user.id))
    return render_template('company/publish_job.html', form=form, company_id=company_id)
Example #2
0
def job_edit(company_id):
    job = Job.query.filter_by(company_id=company_id).first()
    form = JobForm(obj=job)
    if form.validate_on_submit():
        form.update_job(job)
        flash('职位更新成功', 'success')
        return redirect(url_for('company.manage_job', company_id=company_id))
    return render_template('company/job_edit.html',
                           form=form,
                           company_id=company_id)
Example #3
0
def edit_job(job_id):
    job = Job.query.get_or_404(job_id)  #首先找到当前要修改的job
    if not current_user.company.id == job.company_id:
        abort(404)
    form = JobForm(obj=job)
    if form.validate_on_submit():
        form.edit_job(job_id)  #传入要修改的job_id
        flash('工作更新成功', 'success')
        return redirect(url_for('company.edit_job', job_id=job_id))
    return render_template('company/edit_job.html', form=form, job=job)
Example #4
0
def admin_edit_job(company_id, job_id):
    job = Job.query.get_or_404(job_id)
    if current_user.id != company_id or job.company_id != current_user.id:
        abort(404)
    form = JobForm(obj=job)
    if form.validate_on_submit():
        form.update_job(job)
        flash('职位更新成功', 'success')
        return redirect(url_for('company.admin_index', company_id=company_id))
    return render_template('company/admin_edit_job.html', form=form, company_id=company_id, job=job)
Example #5
0
def admin_addjob(company_id):
    company = Company.query.get_or_404(company_id)
    form = JobForm()
    if form.validate_on_submit():
        form.create_job(company)
        flash('职位发布成功!', 'success')
        return redirect(url_for('.admin_index', company_id=company.id))
    return render_template('company/admin_addjob.html',
                           form=form,
                           company=company)
Example #6
0
def admin_add_job(company_id):
    if current_user.id != company_id:
        abort(404)
    form = JobForm()
    if form.validate_on_submit():
        job = form.create_job(current_user)
        db.session.add(job)
        db.session.commit()
        flash('职位创建成功', 'success')
        return redirect(url_for('company.admin_index', company_id=current_user.id))
    return render_template('company/admin_add_job.html', form=form, company_id=company_id)
Example #7
0
def job_edit(job_id):
    if current_user.role != 20:
        abort(404)
    job = Job.query.get_or_404(job_id)
    if job.company_id != current_user.id:
        abort(404)
    form = JobForm(obj=job)
    if form.validate_on_submit():
        form.update_job(job)
        flash('职位更新成功!', 'success')
        return redirect(url_for('company.company_admin'))
    return render_template('company/job_edit.html', form=form, job=job)
Example #8
0
def admin_editjob(company_id, job_id):
    company = Company.query.get_or_404(company_id)
    job = Job.query.get_or_404(job_id)
    form = JobForm(obj=job)
    if form.validate_on_submit():
        form.update_job(job)
        flash('职位更新成功!', 'success')
        return redirect(url_for('.admin_index', company_id=company.id))
    return render_template('company/admin_editjob.html',
                           form=form,
                           company=company,
                           job=job)
Example #9
0
def admin_edit_job(companyID, jobID):
    if current_user.id != companyID:
        abort(404)
    jobObject = Job.query.get_or_404(jobID)
    if jobObject.companyID != companyID:
        abort(404)
    form = JobForm(obj=jobObject)
    if form.validate_on_submit():
        form.update_job(jobObject)
        flash('职位更新成功', 'success')
        return redirect(url_for('company.admin_index', companyID=companyID))
    return render_template('company/edit_job.html', form=form, companyID=companyID, job=jobObject)
Example #10
0
def admin_edit_job(company_id, job_id):
    if current_user.id != company_id:
        abort(404)
    job = Job.query.get_or_404(job_id)
    if job.company_id != current_user.id:
        abort(404)
    form = JobForm(obj=job)
    if form.validate_on_submit():
        form.update_job(job)
        flash('职位更新成功', 'success')
        return redirect(url_for('company.admin_index', company_id=current_user.id))
    return render_template('company/edit_job.html', form=form, company_id=company_id, job=job)
Example #11
0
def admin_publish_job(company_id):
    if current_user.id != company_id:
        abort(404)
    form = JobForm()
    if form.validate_on_submit():
        form.create_job(current_user)
        flash('Create Job Success', 'success')
        return redirect(
            url_for('company.admin_index', company_id=current_user.id))
    return render_template('company/publish_job.html',
                           form=form,
                           company_id=company_id)
Example #12
0
def publish_job(company_id):
    if current_user.company.id != company_id:
        abort(404)

    form = JobForm()

    if form.validate_on_submit():
        form.create_job(current_user.company)
        flash('新增职位成功', 'success')
        return redirect(url_for('company.admin', company_id=company_id))
    return render_template('company/publish_job.html',
                           company_id=company_id,
                           form=form)
Example #13
0
def publish_job():
    """
    发布职位
    """
    company = Company.query.filter(Company.user == current_user).first()
    form = JobForm()
    if form.validate_on_submit():
        form.create_job(company)
        flash("职位创建成功", "success")
        return redirect(url_for("company.manage_job"))
    return render_template("company/publish_job.html",
                           form=form,
                           company_id=company.id)
Example #14
0
def edit_job():
    """
    编辑职位
    """
    job_id = request.args.get("job_id", "")
    job = Job.query.get_or_404(job_id)
    company_id = Company.query.filter_by(user_id=current_user.id).value("id")
    if job.company_id != company_id:
        abort(404)
    form = JobForm(obj=job)
    if form.validate_on_submit():
        form.update_job(job)
        flash("职位更新成功", "success")
        return redirect(url_for("company.manage_job"))
    return render_template("company/edit_job.html", form=form, job=job)
Example #15
0
def create_job():
    form = JobForm()
    form.update_companylist()
    if form.validate_on_submit():
        form.create_job()
        flash('Job create success', 'success')
        return redirect(url_for('admin.joblist'))
    return render_template('admin/create_job.html', form=form)
Example #16
0
def edit_job(job_id):
    job = Job.query.get_or_404(job_id)
    form = JobForm(obj=job)
    form.update_companylist()
    if form.validate_on_submit():
        form.update_job(job)
        flash('User update success', 'success')
        return redirect(url_for('admin.joblist'))
    return render_template('admin/edit_job.html', form=form, job=job)
Example #17
0
def create_job():
    company_id = current_user.company.id
    form = JobForm()
    form.update_companylist()
    form.company_id.data = company_id
    if form.validate_on_submit():
        form.create_job()
        flash('Job create success', 'success')
        return redirect(url_for('company.admin_jobs'))
    return render_template('company/admin/add_job.html', form=form)
Example #18
0
def job_edit():
    job_id = request.args.get('job_id')
    try:
        job_id = int(job_id)
    except TypeError:
        pass
    if job_id:
        job = Job.query.get_or_404(job_id)
        form = JobForm(obj=job)
        if form.validate_on_submit():
            form.populate_obj(job)
            form.create_job(job)
            flash('修改成功', 'success')
            return redirect(url_for('company.job'))
    else:
        job = Job()
        form = JobForm()
    if form.validate_on_submit():
        # 增加缺少的数据
        job_id = Company.query.filter_by(user_id=current_user.id).id
        job.id = job.job_id
        job.state = 1
        form.populate_obj(job)
        form.create_job(job)
        flash('创建成功', 'success')
    return render_template('company/admin_job_edit.html', form=form)
Example #19
0
def new():
    form = JobForm()
    if form.validate_on_submit():
        form.create_job()
        return redirect(url_for('job.admin'))
    return render_template('job/create_job.html', form=form)