Пример #1
0
def thread_create():
    thread = Thread(request.form.get("subject"), request.form.get("text"),
                    current_user.id)

    if not thread.validate():
        return thread_index(thread_create=thread, show_errors=True)

    db.session().add(thread)
    db.session().commit()

    return thread_index()
Пример #2
0
def thread_create():

    threadform = ThreadForm(request.form)

    if not threadform.validate():
        return render_template("thread/new.html", form=threadform)

    t = Thread(title=threadform.title.data, content=threadform.content.data)
    t.account_id = current_user.id

    db.session().add(t)
    db.session().commit()

    return redirect(url_for("thread_index"))
Пример #3
0
def thread_index(threads=None,
                 thread_create=Thread("", "", None),
                 show_errors=False,
                 search_text=None,
                 tag=None):

    if threads == None:
        threads = Thread.thread_list()

    return render_template("thread_index.html",
                           threads=threads,
                           thread_create=thread_create,
                           show_errors=show_errors,
                           search_text=search_text,
                           tag=tag)
Пример #4
0
def thread_show(thread_id):
    form = CommentForm(request.form)
    thread = Thread.query.get(thread_id)

    return render_template("thread/show.html",
                           form=form,
                           thread=thread,
                           threadinfo=Thread.threadsInfo(thread_id),
                           comment=Comment.listComments(thread_id))
Пример #5
0
def thread_index():
    return render_template("thread/list.html",
                           listthreads=Thread.listAllThreads())
Пример #6
0
def thread_find_tag_id(tag_id):
    return thread_index(threads=Thread.find_tag_id(tag_id),
                        tag=Tag.query.get(tag_id))
Пример #7
0
def thread_search():
    search_text = request.form.get("text")
    return thread_index(threads=Thread.search(search_text),
                        search_text=search_text)