当前位置: 首页>>代码示例>>Python>>正文


Python AnswerForm.process方法代码示例

本文整理汇总了Python中forms.AnswerForm.process方法的典型用法代码示例。如果您正苦于以下问题:Python AnswerForm.process方法的具体用法?Python AnswerForm.process怎么用?Python AnswerForm.process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在forms.AnswerForm的用法示例。


在下文中一共展示了AnswerForm.process方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: editQuestions

# 需要导入模块: from forms import AnswerForm [as 别名]
# 或者: from forms.AnswerForm import process [as 别名]
def editQuestions():
    [now,tomorrow]=getTiming()

    form = AnswerForm(request.form)
    rform=request.form
    user=User.query.filter_by(userName=session['userName']).first() 
    deadlinePassed=False
    firstGame=Games.query.filter_by(game='MD1-G01').first()
    startDate=firstGame.date
    if now.date()>=startDate:
        deadlinePassed=True

    
    saved=0
    save=None
   
    if request.method =='POST':
        error=None
        if user.activated==True:
            getAnswers(rform,user)
            questions=UserQuestions.query.filter_by(parent_id=user.user_id).all()
#            answers_ned=['']*len(questions)
#            answers_en=['']*len(questions)
#            postman=[0]*len(questions)
            
            for item in questions:
                if str(item.answer_id) =='5': 
                    import ast
                    answer5=ast.literal_eval(item.answer)
                    for item in answer5:
                        if answer5[item]!='empty' and answer5[item]!='' and answer5[item]!=None:
                            saved=saved+1
                else:
                    if item.answer !='empty' and item.answer!='' and item.answer!=None:
                        saved=saved+1
                
                save=True
        else: #user not activated
            error=""" Your account is not yet activated. You can checkout the app, but your input won't be saved
                      since the payment is not yet confirmed."""
                   
        
        questions=Questions.query.all()  
        questions.sort(key=lambda x: x.id)       
        return render_template('editQuestions.html', form=form,questions=questions,saved=saved,\
                                save=save,\
                                deadlinePassed=deadlinePassed,error=error)
        
    if request.method == 'GET':
        error=None
        questions=UserQuestions.query.filter_by(parent_id=user.user_id).all()
#        answers_ned=['']*len(questions)
#        answers_en=['']*len(questions)
#        postman=[0]*len(questions)
        for item in questions:
            if str(item.answer_id) =='5': 
                import ast
                answer5=ast.literal_eval(item.answer)
                form["answer5A"].default=answer5['A']
                form["answer5B"].default=answer5['B']
                form["answer5C"].default=answer5['C']
                form["answer5D"].default=answer5['D']
                form["answer5E"].default=answer5['E']
                form["answer5F"].default=answer5['F']
                for item in answer5:
                    if answer5[item]!='empty' and answer5[item]!='' and answer5[item]!=None:
                        saved=saved+1

            else:
                form['answer{0}'.format(item.answer_id)].default=item.answer
                if item.answer !='empty' and item.answer!='' and item.answer!=None:
                    saved=saved+1
        
        form.process()
                   
        questions=Questions.query.all()  
        questions.sort(key=lambda x: x.id)       

        return render_template('editQuestions.html', form=form,questions=questions,saved=saved,\
                                save=save, \
                                deadlinePassed=deadlinePassed,error=error)
开发者ID:sennevanbaelen,项目名称:EKbetass,代码行数:83,代码来源:views.py

示例2: enterAnswers

# 需要导入模块: from forms import AnswerForm [as 别名]
# 或者: from forms.AnswerForm import process [as 别名]
def enterAnswers():
    form = AnswerForm(request.form)
    rform=request.form
    questions=Questions.query.all()
           
    saved=0
    save=None
    
    if request.method =='POST':
                
        getAnswers(rform)
        
        for item in questions:
            if str(item.id) =='5': 
                import ast
                answer5=ast.literal_eval(item.answer)
                for item in answer5:
                    if answer5[item]!='empty' and answer5[item]!='' and answer5[item]!=None:
                        saved=saved+1
            else:
                if item.answer !='empty' and item.answer!='' and item.answer!=None:
                    saved=saved+1
            
            save=True
        

        
        questions=Questions.query.all()     
        questions.sort(key=lambda x: x.id)       

        return render_template('answerQuestions.html', form=form,questions=questions,saved=saved,\
                                save=save)
        
    if request.method == 'GET':
        
        for item in questions:
            if str(item.id) =='5': 
                import ast
                try:
                    answer5=ast.literal_eval(item.answer)
                    form["answer5A"].default=answer5['A']
                    form["answer5B"].default=answer5['B']
                    form["answer5C"].default=answer5['C']
                    form["answer5D"].default=answer5['D']
                    form["answer5E"].default=answer5['E']
                    form["answer5F"].default=answer5['F']
                    for item in answer5:
                        if answer5[item]!='empty' and answer5[item]!='' and answer5[item]!=None:
                            saved=saved+1
                except:
                    print "NAAA"

            else:
                form['answer{0}'.format(item.id)].default=item.answer
                if item.answer !='empty' and item.answer!='' and item.answer!=None:
                    saved=saved+1
        
        form.process()

        questions=Questions.query.all()     
        questions.sort(key=lambda x: x.id)       

        return render_template('answerQuestions.html', form=form,questions=questions,saved=saved,\
                                save=save)
开发者ID:sennevanbaelen,项目名称:EKbetass,代码行数:66,代码来源:views.py


注:本文中的forms.AnswerForm.process方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。