def new(): board_id = int(request.args.get('board_id', -1)) bs = Board.all() # return render_template("topic/new.html", bs=bs, bid=board_id) token = new_csrf_token() return render_template("topic/new.html", bs=bs, token=token, bid=board_id, hots=Topic.hots(), user=current_user())
def detail(id): m = Topic.get(id) # 当存在时返回页面,不存在返回主页 if m: # 传递 topic 的所有 reply 到 页面中 return render_template("topic/detail.html", topic=m, user=current_user(), hots=Topic.hots()) else: return redirect(url_for('.index'))
def index(): u = current_user() sent_mail = Mail.all(sender_id=u.id) received_mail = Mail.all(receiver_id=u.id) t = render_template('mail/index.html', send=sent_mail, received=received_mail, hots=Topic.hots(), user=current_user()) return t
def user_profile(username): # u = User.find_by(username=username) u = User.one(username=username) if u is None: abort(404) else: # topics = Topic.find_all(user_id=u.id) topics = Topic.all(user_id=u.id) reply_topic = Topic.user_participated(u) return render_template('user.html', user=u, reply_topic=reply_topic, topics=topics, hots=Topic.hots(), u=current_user())
def index(): board_id = int(request.args.get('board_id', -1)) hots = Topic.hots() if board_id == -1: ms = Topic.all(deleted=0) else: # ms = Topic.find_all(board_id=board_id) ms = Topic.all(board_id=board_id, deleted=0) token = new_csrf_token() bs = Board.all() user = current_user() return render_template("topic/index.html", ms=ms, token=token, bs=bs, bid=board_id, user=user, hots=hots)