コード例 #1
0
def editOneProblem():
    form = EditProblemForm().validateForApi()
    userId = g.userInfo.userId
    Problem.editOneProblem(ownerId=userId,
                           problemId=form.problemId.data,
                           form=form)
    return Success(information="编辑问题成功")
コード例 #2
0
def editQuestionnaire():
    userId = g.userInfo.userId
    form = QuestionnaireForm().validateForApi()
    Questionnaire.editQuestionnaire(ownerId=userId,
                                    questionnaireId=form.questionnaireId.data,
                                    form=form)
    return Success(information="编辑问卷成功")
コード例 #3
0
def getAnalysisDataByPid(pid):
    userId = g.userInfo.userId
    problems = Problem.objects.filter(problemId=pid, ownerId=userId).first()
    if not problems:
        raise NoProblem
    res = problems.getResolution()
    return Success(information="获取分析数据成功", payload={'problemResolution': res})
コード例 #4
0
def deleteQuestionnaire():
    userId = g.userInfo.userId
    form = DeleteQuestionnaireForm().validateForApi()
    Problem.deleteProblems(ownerId=userId,
                           questionnaireId=form.questionnaireId.data)
    Questionnaire.deleteQuestionnaire(
        ownerId=userId, questionnaireId=form.questionnaireId.data)
    return Success(information="删除问卷成功")
コード例 #5
0
def getAllQuestionnaire():
    userId = g.userInfo.userId
    res = Questionnaire.getAllQuestionnaire(ownerId=userId)
    tlen = Questionnaire.getTemplatesAmount()
    return Success(information="获取用户问卷数据成功",
                   payload={
                       "questionnaires": res,
                       "tAmount": tlen
                   })
コード例 #6
0
def submitCompleteData(qid):
    c = Complete()
    # 生产环境
    if not current_app.config['DEBUG']:
        c.createCompleteData(qid=qid, data=request.json, ip=request.headers['X-Real-Ip'])
    # 开发环境
    else:
        c.createCompleteData(qid=qid, data=request.json)
    return Success(information="提交成功 感谢您的参与~")
コード例 #7
0
def userLogin():
    form = UserForm().validateForApi()
    # 登录类型
    types = {
        UserTypeEnum.WEB_USER: User.userLogin,
        UserTypeEnum.MINI_PROGRAM_USER: User.userLoginByWeChat
    }
    u = types[form.type.data](form.userName.data, form.secret.data)
    token = generateAuthToken(userId=u.getUserId(), clientType=form.type.data.name)
    return Success(information="登录成功", payload={"token": token})
コード例 #8
0
def deleteOneProblem():
    form = DeleteProblemForm().validateForApi()
    userId = g.userInfo.userId
    Problem.deleteOneProblem(ownerId=userId, problemId=form.problemId.data)
    return Success(information="删除问题成功")
コード例 #9
0
def appendOneProblem():
    userId = g.userInfo.userId
    form = ProblemForm().validateForApi()
    pid = Problem().appendOneProblem(ownerId=userId, form=form)
    return Success(information="新建问题成功", payload={"problemId": pid})
コード例 #10
0
def getAnalysisData(qid):
    res = Questionnaire.getAnalysisData(qid)
    return Success(information="获取分析数据成功", payload=res)
コード例 #11
0
def getTemplates():
    form = GetTemplatesForm().validateForApi()
    data = Questionnaire.getTemplatesBasicInfo(int(form.page.data))
    return Success(information='获取问卷模板成功', payload={"data": data})
コード例 #12
0
def getCondition(qid):
    r = Questionnaire.getConditions(questionnaireId=qid, isAdmin=True)
    return Success(information="获取问卷状态成功", payload=r)
コード例 #13
0
def checkSecretKey(qid):
    form = QuestionireSecretCheckForm().validateForApi()
    res = Questionnaire.checkSecretKey(questionnaireId=qid, key=form.secretKey.data)
    return Success(information="验证成功", payload=res)
コード例 #14
0
def checkToken():
    info = g.userInfo
    return Success(information="验证成功", payload={"clientType": info.clientType})
コード例 #15
0
def getProfileData():
    userId = g.userInfo.userId
    user = User.objects.filter(id=userId).first()
    return Success(information="信息获取成功", payload=user.getProfleJson())
コード例 #16
0
def getQuestionnaire(qid):
    userId = g.userInfo.userId
    res = Questionnaire.getQuestionnaire(ownerId=userId,
                                         questionnaireId=qid,
                                         isAdmin=True)
    return Success(information="获取问卷成功", payload=res)
コード例 #17
0
def copyTemplates():
    userId = g.userInfo.userId
    form = CopyTemplatesForm().validateForApi()
    Questionnaire.copyTemplates(qid=form.templateId.data, uid=userId)
    return Success(information='更新成功')
コード例 #18
0
def hello_world():
    return Success(information="your project is running now~ (◕ᴗ◕✿)")
コード例 #19
0
def getProblemByPid(problemId):
    userId = g.userInfo.userId
    res = Problem.getOneProblemByPid(pid=problemId, oid=userId)
    return Success(information='更新成功', payload=res)
コード例 #20
0
def createQuestionnaire():
    userId = g.userInfo.userId
    qid = Questionnaire().createQuestionnaire(ownerId=userId)
    return Success(information="新建问卷成功", payload={"questionnaireId": qid})
コード例 #21
0
def userRegister():
    form = WebRegisterForm().validateForApi()
    # 创建新用户
    newUser = User()
    newUser.userRegister(userName=form.userName.data, password=form.secret.data)
    return Success(information="注册成功啦~")