Exemple #1
0
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))
Exemple #2
0
def changeHeadPortrait():
    if request.method == "POST":
        form = JPGAndPNGForm(CombinedMultiDict([request.files, request.form]))
        if form.validate_on_submit():
            if fileUtil.saveToRes(path="user/headPortrait",
                                  uploadFile=form.image.data,
                                  fileName=str(current_user.id) + ".png"):
                return render_template("changeHeadPortrait.html")
            else:
                return errorUtil.getData("changeHeadPortraitError")
        return errorUtil.getData("FormDataWrong", form.errors)
    return render_template("changeHeadPortrait.html")
Exemple #3
0
 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 getHeadPortrait(ID):
    try:
        return fileUtil.getFromRes(path="user/headPortrait", fileName=str(ID) + ".png")
    except Exception as e:
        MainLog.record(MainLog.level.WARN,"可能发生了盗取用户信息")
        MainLog.record(MainLog.level.WARN,e)
        return JsonUtil().dictToJson(errorUtil.getData('backEndWrong2'))
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 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 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)
Exemple #13
0
def editLaboratory():
    form = EditLaboratory(request.form)
    if form.validate_on_submit():
        return "0"
    return errorUtil.getData('FormDataWrong',
                             message=JsonUtil().dictToJson(form.errors))