Exemplo n.º 1
0
def edit_user(user_id):
    user = User.query.get_or_404(user_id)
    if user.is_company:
        form = CompanyEditForm(obj=user)
        form.website.data = user.company_msg.website
    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)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)