def editMyBaseData(): form = EditMyBaseData(request.form) if form.validate_on_submit(): if userControler.editUser(current_user.id, form): return successUtil.getData('editMyBaseDataSuccess') else: return errorUtil.getData('dataBaseError') return errorUtil.getData('FormDataWrong', message=JsonUtil().dictToJson(form.errors))
def addProfessionalClass(): messageDict = [ 'updateProfessionalClassSuccess', 'dataBaseError', ] result = ProfessionalClass.addProfessionalClass("网络工程", 16, 1) if result == 0: return successUtil.getData(messageDict[result]) else: return errorUtil.getData(messageDict[result])
def updateLaboratory(): messageDict = [ 'updateLaboratorySuccess', 'dataBaseError', ] result = Laboratory.updateLaboratory("E", "601", "特别难爬的一实验室") if result == 0: return successUtil.getData(messageDict[result]) else: return errorUtil.getData(messageDict[result])
def updateDirection(): messageDict = [ 'updateDirectionSuccess', 'dataBaseError', ] result = Direction.updateDirection("Java", "Java", "Java世界最牛逼") if result == 0: return successUtil.getData(messageDict[result]) else: return errorUtil.getData(messageDict[result])
def editPermission(): if request.method == 'POST': messageDict = [ 'editPermissionSuccess', 'UserNameNone', 'dataBaseError', ] result = adminControler.givePermission(request.json) if result == 0: return successUtil.getData(messageDict[result]) else: return errorUtil.getData(messageDict[result]) return render_template('permissionEdit.html')
def delLoginNotice(): messageDict = [ 'delLoginNoticeSuccess', 'LoginNoticeIdNone', 'LoginNoticeNone', 'dataBaseError', 'editLoginNoticeImageError', ] result = adminControler.delLoginNotice(request.form['id']) if result == 0: return successUtil.getData(messageDict[result]) else: return errorUtil.getData(messageDict[result])
def mark(self): messageDict = ["markSuccess", "markIpError"] flag = self.__validation() if flag == 0: try: db.session.add( Mark(dateTime=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), userId=current_user.id)) except: return errorUtil.getData("backEndWrong2") db.session.commit() return successUtil.getData(messageDict[flag]) else: return errorUtil.getData(messageDict[flag])
def register(): if current_user.is_authenticated: return redirect(url_for('panel.index')) form = RegisterForm() if request.method == 'POST': if form.validate_on_submit(): if form.validate_userName(form.schoolNum): if form.validata_Num(): if userControler.addUser(form): return successUtil.getData('registerSuccess') else: return errorUtil.getData('backEndWrong2') return errorUtil.getData('FormDataWrong') return errorUtil.getData('UserNameExist') return errorUtil.getData('FormDataWrong',message=JsonUtil().dictToJson(form.errors)) return render_template('newRegister.html', form=form)
def login(): if current_user.is_authenticated: return redirect(url_for('panel.index')) # TAG 测试时关闭csrf保护,接口开发完毕打开 form = LoginForm(request.form,csrf_enabled=False) if request.method == 'POST': if form.validate(): user = User.query.filter_by(schoolID=form.userName.data).first() if user is not None: if user.verify_password(form.password.data): login_user(user) return successUtil.getData('loginSuccess') return errorUtil.getData('PasswordWrong') return errorUtil.getData('UserNameNone') return errorUtil.getData('FormDataWrong',message=JsonUtil().dictToJson(form.errors)) return render_template('login.html', form=form)
def addLoginNotice(): # 文件是从request,files里面获取,这里使用CombinedMultiDict把form和file的数据组合起来,一起验证 form = LoginNoticeForm(CombinedMultiDict([request.files, request.form])) if request.method == "POST": if form.validate_on_submit(): messageDict = [ 'addLoginNoticeSuccess', 'LoginNoticeMax6', 'dataBaseError', 'addLoginNoticeImageError', ] result = adminControler.addLoginNotice(form) if result == 0: return successUtil.getData(messageDict[result]) else: return errorUtil.getData(messageDict[result]) return form.errors return render_template("loginNoticeEdit.html", form=form)