def profile(): form = UserEditForm(obj=current_user) if form.validate_on_submit(): form.updated_profile(current_user) flash('个人信息更新成功', 'success') return redirect(url_for('front.index')) return render_template('user/profile.html', form=form)
def user_edit(user_id): user = User.query.get_or_404(user_id) form = UserEditForm() if form.validate_on_submit(): form.update_user(user) flash('用户信息更新成功', 'success') return redirect(url_for('admin.user_manage')) return render_template('admin/user_edit.html', form=form, user=user)
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')) return render_template('admin/edit_user.html', form=form, user=user)
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)
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)