Esempio n. 1
0
 def save(self):
     question = Question(**self.cleaned_data)
     if question.author_id:
         question.author_id += 1
     else:
         question.author_id = 1
     question.save()
     return question
Esempio n. 2
0
    def post(self):
        title = request.form.get('title')
        content = request.form.get('content')
        question = Question(title=title, content=content)

        question.author_id = session.get('user_id')

        db.session.add(question)
        db.session.commit()
        return redirect(url_for('index'))
Esempio n. 3
0
def question():
    print('question page')
    if request.method == 'GET':
        return render_template('question.html')
    else:
        submitted_question = Question()
        submitted_question.title = request.form.get('title')
        submitted_question.content = request.form.get('content')
        submitted_question.create_time = datetime.now()
        submitted_question.author_id = session.get('user_id')
        db.session.add(submitted_question)
        db.session.commit()
        return redirect(url_for('index'))
Esempio n. 4
0
def question():
    if request.method == "GET":
        return render_template("question.html")
    else:
        title = request.form.get('title')
        content = request.form.get('content')
        question = Question(title=title, content=content)
        user_id = session.get('user_id')
        user = User.query.filter(User.id == user_id).first()
        question.author_id = user.id
        db.session.add(question)
        db.session.commit()
        return redirect(url_for("index"))
Esempio n. 5
0
def filldb(request, cou):
    for x in range(0, int(cou)):
        q = Question(title="Question #" + str(x),
                     text="Just a question with number " + str(x))
        q.rating = x
        q.author_id = 1
        q.added_at = date(2016, 03, 1 + x)
        q.save()
        q.added_at = date(2016, 03, 1 + x)
        for y in range(1, x + 2):
            a = Answer(text="answer #" + str(y) + " for question #" + str(x))
            a.author_id = 1
            q.answer_set.add(a)
        q.save()
    return HttpResponse("OK")
Esempio n. 6
0
def filldb(request, cou):
    for x in range(0, int(cou)):
        q = Question(title = "Question #"+str(x),
                     text = "Just a question with number "+str(x))
        q.rating = x
        q.author_id = 1
        q.added_at = date(2016, 03, 1+x)
        q.save()
        q.added_at = date(2016, 03, 1+x)
        for y in range(1, x+2):
            a = Answer(text = "answer #"+str(y)+" for question #"+str(x))
            a.author_id = 1
            q.answer_set.add(a)
        q.save()
    return HttpResponse("OK")
Esempio n. 7
0
def question():

    if request.method == 'POST':
        title = request.form.get('title')
        content = request.form.get('content')

        question = Question(title=title, content=content)
        userid = session.get('user_id')
        if userid:
            user = User.query.filter(User.id==userid).first()
            question.author_id = user.id
            db.session.add(question)
            db.session.commit()

        return redirect(url_for('index'))
    return render_template('questions.html')
Esempio n. 8
0
 def save(self):
     print 'AskF save: (%s)' % (self.cleaned_data)
     quest = Question(**self.cleaned_data)
     quest.author_id = 1
     quest.save()
     return quest
Esempio n. 9
0
 def save(self):
     print 'AskF save: (%s)' % (self.cleaned_data)
     quest = Question(**self.cleaned_data)
     quest.author_id = 1
     quest.save()
     return quest
Esempio n. 10
0
 def save(self):
     question = Question(**self.cleaned_data)
     question.author_id = 1
     question.save()
     return question
Esempio n. 11
0
 def save(self):
     question = Question(**self.cleaned_data)
     question.author_id = self._user.id
     question.save()
     return question