def edit_user(): if not current_user.is_admin and not current_user.is_coach: return redirect(url_for('main.index')) try: has_one = user_server.get_by_id(request.args['p']) except : return redirect(url_for('admin.manage_user')) user_modify_form = form.UserModifyForm() if has_one: user_modify_form.id.data = has_one.id user_modify_form.name.data = has_one.name user_modify_form.stu_id.data = has_one.stu_id user_modify_form.email.data = has_one.email user_modify_form.phone.data = has_one.phone user_modify_form.motto.data = has_one.remark user_modify_form.situation.data = has_one.situation user_modify_form.school.data = has_one.school user_modify_form.college.data = has_one.college user_modify_form.grade.data = has_one.grade user_modify_form.gender.data = '1' if has_one.gender else '0' user_modify_form.active.data = '1' if has_one.active else '0' return render_template('edit_user.html', title = u'修改用户信息', user = has_one, user_modify_form = user_modify_form)
def edit_user(): if not current_user.is_admin and not current_user.is_coach: return redirect(url_for('main.index')) try: has_one = user_server.get_by_id(request.args['p']) except: return redirect(url_for('admin.manage_user')) user_modify_form = form.UserModifyForm() if has_one: user_modify_form.id.data = has_one.id user_modify_form.name.data = has_one.name user_modify_form.stu_id.data = has_one.stu_id user_modify_form.email.data = has_one.email user_modify_form.phone.data = has_one.phone user_modify_form.motto.data = has_one.remark user_modify_form.situation.data = has_one.situation user_modify_form.school.data = has_one.school user_modify_form.college.data = has_one.college user_modify_form.grade.data = has_one.grade user_modify_form.gender.data = '1' if has_one.gender else '0' user_modify_form.active.data = '1' if has_one.active else '0' return render_template('edit_user.html', title=u'修改用户信息', user=has_one, user_modify_form=user_modify_form)
def check_apply(): if not current_user.is_admin and not current_user.is_coach: return redirect(url_for('main.index')) try: apply_id = request.form.get('uid') user = user_server.get_by_id(apply_id) opt = request.form.get('opt') ret = user_server.update_apply(apply_id, opt) if ret == 'OK': function.reply_of_apply(mail, user.serialize, _app_ctx_stack.top, opt) return ret except Exception: return u'操作失败'
def delete_account(): try: profile_user = user_server.get_by_id(request.form.get('user_id')) except: profile_user = current_user if profile_user != current_user and\ (not current_user.is_admin and not current_user.is_coach_of(profile_user)): return u"没有权限" try: account_id = request.form.get('account_id') account_server.delete_account_by_id(profile_user, account_id) return u"OK" except AccountUpdatingException, e: return 'ERROR: ' + e.message
def update_account(): try: profile_user = user_server.get_by_id(request.form.get('user_id')) except: profile_user = current_user if profile_user != current_user and\ (not current_user.is_admin and not current_user.is_coach_of(profile_user)): return u"没有权限" try: account_id = request.form.get('account_id') account_server.update_account_by_id(account_id) return u"ok" except AccountUpdatingException, e: current_app.logger.error(traceback.format_exc()) return 'ERROR: ' + e.message