Beispiel #1
0
def save_questions(questions_yes, request):
    user = None
    if request.user.is_authenticated():
        user = request.user
    for question, details in questions.items():
        question_model = QuestionModel.get_by_question(question)
        if not question_model:
            populate_questions()
            question_model = QuestionModel.get_by_question(question)
        q = Question(question=question_model,
                     user=user,
                     session_key=request.session.session_key)
        if question in questions_yes:
            q.answer = True
        else:
            q.answer = False
        q.save()
Beispiel #2
0
def populate_questions():
    for question, details in questions.items():
        question_model = QuestionModel.get_by_question(question)
        if not question_model:
            # New Question - add it
            yes = details['yes']
            no = details['no']
            why = details['why']
            question_model = QuestionModel(question=question,
                                           answer_yes=yes,
                                           answer_no=no,
                                           why=why)
            question_model.save()