def user_collect_works(user_abbr): user = User.get_user_by_abbr(user_abbr) user_name = '我' if "user_id" in session and session['user_id'] == user[ 'UserID'] else user['Name'] # pagination num_per_page = 10 page = int(request.args['page'] if 'page' in request.args else 1) works = Collect.get_works_by_user(user['UserID'], page, num_per_page) for work in works: work['Content'] = content_clean(work['Content']) works_num = Collect.get_works_num_by_user(user['UserID']) # page paras total_page = int(math.ceil(works_num / num_per_page)) pre_page = (page - 1) if page > 1 else 1 if total_page == 0: next_page = 1 elif page < total_page: next_page = page + 1 else: next_page = total_page return render_template('user/user_collect_works.html', user=user, works=works, works_num=works_num, user_name=user_name, page=page, total_page=total_page, pre_page=pre_page, next_page=next_page)
def user_collect_works(user_abbr): user = User.get_user_by_abbr(user_abbr) user_name = '我' if "user_id" in session and session['user_id'] == user['UserID'] else user['Name'] # pagination num_per_page = 10 page = int(request.args['page'] if 'page' in request.args else 1) works = Collect.get_works_by_user(user['UserID'], page, num_per_page) for work in works: work['Content'] = content_clean(work['Content']) works_num = Collect.get_works_num_by_user(user['UserID']) # page paras total_page = int(math.ceil(works_num / num_per_page)) pre_page = (page - 1) if page > 1 else 1 if total_page == 0: next_page = 1 elif page < total_page: next_page = page + 1 else: next_page = total_page return render_template('user/user_collect_works.html', user=user, works=works, works_num=works_num, user_name=user_name, page=page, total_page=total_page, pre_page=pre_page, next_page=next_page)
def user(user_abbr): user = User.get_user_by_abbr(user_abbr) is_me = True if "user_id" in session and session['user_id'] == user[ 'UserID'] else False # works works = Collect.get_works_by_user(user['UserID'], 1, 3) for work in works: work['Content'] = content_clean(work['Content']) works_num = Collect.get_works_num_by_user(user['UserID']) # reivews reviews = Review.get_reviews_by_user(user['UserID'], 1, 3, is_me) for r in reviews: r['Time'] = time_diff(r['Time']) reviews_num = Review.get_reviews_num_by_user(user['UserID'], is_me) # topics topics = Topic.get_topics_by_user(user['UserID'], 1, 3) for t in topics: t['Time'] = time_diff(t['Time']) topics_num = Topic.get_topics_num_by_user(user['UserID']) return render_template('user/user.html', user=user, works=works, works_num=works_num, reviews=reviews, reviews_num=reviews_num, topics=topics, topics_num=topics_num)
def user(user_abbr): user = User.get_user_by_abbr(user_abbr) is_me = True if "user_id" in session and session['user_id'] == user['UserID'] else False # works works = Collect.get_works_by_user(user['UserID'], 1, 3) for work in works: work['Content'] = content_clean(work['Content']) works_num = Collect.get_works_num_by_user(user['UserID']) # reivews reviews = Review.get_reviews_by_user(user['UserID'], 1, 3, is_me) for r in reviews: r['Time'] = time_diff(r['Time']) reviews_num = Review.get_reviews_num_by_user(user['UserID'], is_me) # topics topics = Topic.get_topics_by_user(user['UserID'], 1, 3) for t in topics: t['Time'] = time_diff(t['Time']) topics_num = Topic.get_topics_num_by_user(user['UserID']) return render_template('user/user.html', user=user, works=works, works_num=works_num, reviews=reviews, reviews_num=reviews_num, topics=topics, topics_num=topics_num)