示例#1
0
def edit_user(user_id):
    user = User.query.get_or_404(user_id)
    if user.is_company:
        form = CompanyEditForm(obj=user)
        if form.validate_on_submit():
            form.update(user)
            flash('更新成功', 'success')
            return redirect(url_for('admin.users'))
    else:
        form = UserEditForm(obj=user)
        if form.validate_on_submit():
            form.update(user)
            flash('更新成功', 'success')
            return redirect(url_for('admin.users'))
    return render_template('admin/edit_user.html', form=form, user=user)
示例#2
0
def company_edit(company_id):
    company = Company.query.get_or_404(company_id)
    form = CompanyEditForm(obj=company)
    if form.validate_on_submit():
        form.update_company(company)
        flash('企业信息更新成功', 'success')
        return redirect(url_for('admin.company_manage'))
    return render_template('admin/company_edit.html',
                           form=form,
                           company=company)
示例#3
0
def profile():
    if not current_user.is_company:
        flash('您不是企业用户', 'warning')
        return redirect(url_for('front.index'))
    form = CompanyEditForm(obj=current_user.company_detail)
    form.name.data = current_user.name
    form.email.data = current_user.email
    if form.validate_on_submit():
        form.update_company(current_user)
        flash('企业信息更新成功', 'success')
        return redirect(url_for('front.index'))
    return render_template('company/profile.html', form=form)
示例#4
0
def edit_user(user_id):
    user = User.query.get_or_404(user_id)
    if user.is_company:
        form = CompanyEditForm(obj=user)
    else:
        form = UserEditForm(obj=user)
    if form.validate_on_submit():
        form.update(user)
        flash('更新成功', 'success')
        return redirect(url_for('admin.users'))
    if user.is_company:
        form.site.data = user.detail.site
        form.description.data = user.detail.description
    return render_template('admin/edit_user.html', form=form, user=user)
示例#5
0
def edit_user(user_id):
    user = User.query.get_or_404(user_id)
    if user.is_company:
        form = CompanyEditForm(obj=user)
    else:
        form = UserEditForm(obj=user)
    if form.validate_on_submit():
        form.update(user)
        flash('编辑用户成功!', 'success')
        return redirect(url_for('admin.users'))
    #if user.is_company:
    #form.site.data = user.company_detail.site
    #form.desription = user.company_detail.description
    return render_template('admin/edit_user.html', form=form, user=user)
示例#6
0
def edit_user(user_id):
    user = User.query.get_or_404(user_id)
    if user.is_company:
        # 由于企业注册的时候只写了user表,没有写company表,所以需要新写入一次
        if not user.company_info:
            company = Company()
            company.user_id = user.id
            company.name = user.name
            db.session.add(company)
            db.session.commit()

        form = CompanyEditForm(obj=user)
    else:
        form = UserEditForm(obj=user)

    if form.validate_on_submit():
        form.update(user)
        flash('更新成功', 'success')
        return redirect(url_for('admin.users'))

    if user.is_company:
        form.site.data = user.company_info.website
        form.description.data = user.company_info.short_description
    return render_template('admin/edit_user.html', form=form, user=user)