當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。