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()
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"))
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)
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))
def thread_index(): return render_template("thread/list.html", listthreads=Thread.listAllThreads())
def thread_find_tag_id(tag_id): return thread_index(threads=Thread.find_tag_id(tag_id), tag=Tag.query.get(tag_id))
def thread_search(): search_text = request.form.get("text") return thread_index(threads=Thread.search(search_text), search_text=search_text)