Example #1
0
def people_topics(user_abbr):
	people = User.get_user_by_abbr(user_abbr)
	user_name = '我' if "user_id" in session and session['user_id'] == people['UserID'] else people['Name']

	# pagination
	num_per_page = 10
	page = int(request.args['page'] if 'page' in request.args else 1)

	topics = Topic.get_topics_by_user(people['UserID'], page, num_per_page)
	for t in topics:
		t['Time'] = time_diff(t['Time'])

	topics_num = Topic.get_topics_num_by_user(people['UserID'])

	# page paras
	total_page = int(math.ceil(topics_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('people_topics.html', people=people, topics=topics, user_name=user_name, page=page, total_page=total_page, pre_page=pre_page, next_page=next_page)
Example #2
0
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)
Example #3
0
def people(user_abbr):
	people = User.get_user_by_abbr(user_abbr)
	user_name = '我' if "user_id" in session and session['user_id'] == people['UserID'] else people['Name']

	works = Love_work.get_works_by_user(people['UserID'], 1, 3)
	for work in works:
		work['Content'] = content_clean(work['Content'])
	works_num = Love_work.get_works_num_by_user(people['UserID'])

	reviews = Review.get_reviews_by_user(people['UserID'], 1, 3)
	for r in reviews:
		r['Time'] = time_diff(r['Time'])
	reviews_num = Review.get_reviews_num_by_user(people['UserID'])

	topics = Topic.get_topics_by_user(people['UserID'], 1, 3)
	for t in topics:
		t['Time'] = time_diff(t['Time'])
	topics_num = Topic.get_topics_num_by_user(people['UserID'])

	return render_template('people.html', people=people, works=works, works_num=works_num, reviews=reviews, reviews_num=reviews_num, topics=topics, topics_num=topics_num, user_name=user_name)
Example #4
0
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)