def auth_setting_add(): add_form = AddForm() task_info = ticket_status() if add_form.validate_on_submit(): user = User( username=add_form.username.data, password=add_form.password.data, alias=add_form.alias.data, role=add_form.role.data, cellphone=add_form.cellphone.data, email=add_form.email.data, manage=add_form.manage.data ) add_sql = edit(user, "username", record=False) add_sql.run('add') flash(u'用户添加成功') else: for th in start_thead: key = th[2] if add_form.errors.get(key, None): flash(add_form.errors[key][0]) break return render_template('auth/add.html', task_info=task_info, sidebar=sidebar, add_form=add_form)
def auth_setting_changepassword(): changepassword_form = ChangePasswordForm() task_info = ticket_status() if changepassword_form.validate_on_submit(): if current_user.verify_password(changepassword_form.old_password.data): value = changepassword_form.password.data change_sql = edit(current_user, "password", value, record=False) change_sql.run('change') flash(u'密码更改成功') else: flash(u'旧密码错误') else: for key in changepassword_form.errors.keys(): flash(changepassword_form.errors[key][0]) return render_template('auth/change.html', task_info=task_info, sidebar=sidebar, changepassword_form=changepassword_form)
def auth_setting_search(): thead = copy.deepcopy(start_thead) task_info = ticket_status() search_value = request.args.get('search', '') checkbox = request.args.getlist('hidden') or request.args.get('hiddens', '') if search_value: thead = init_checkbox(thead, checkbox) page = int(request.args.get('page', 1)) result = search(User, 'username' , search_value) result = result.search_return() if result: pagination = result.paginate(page, 100, False) items = pagination.items return render_template( 'auth/search.html', task_info=task_info, sidebar=sidebar, search_value=search_value, checkbox=str(checkbox), thead=thead, endpoint=endpoint, pagination=pagination, items=items, now=now ) return render_template('auth/search.html', task_info=task_info, sidebar=sidebar, search_value=search_value, thead=thead)