Esempio n. 1
0
def user(user_abbr):
    user = User.query.filter(User.abbr == user_abbr).first_or_404()

    query = user.reviews.order_by(WorkReview.create_time.desc())
    if check_is_me(user.id):
        work_reviews = query.limit(3)
        work_reviews_num = query.count()
    else:
        work_reviews = query.filter(WorkReview.is_publish == True).limit(3)
        work_reviews_num = query.filter(WorkReview.is_publish == True).count()

    topics = user.topics.order_by(Topic.create_time.desc()).limit(3)
    topics_num = user.topics.count()

    work_images = user.work_images.order_by(WorkImage.create_time.desc()).limit(9)
    work_images_num = user.work_images.count()

    return render_template(
        "user/user.html",
        user=user,
        work_reviews=work_reviews,
        work_reviews_num=work_reviews_num,
        topics=topics,
        topics_num=topics_num,
        work_images=work_images,
        work_images_num=work_images_num,
    )
Esempio n. 2
0
def user(user_abbr):
    user = User.query.filter(User.abbr == user_abbr).first_or_404()

    query = user.work_reviews.order_by(WorkReview.create_time.desc())
    if check_is_me(user.id):
        work_reviews = query.limit(3)
        work_reviews_num = query.count()
    else:
        work_reviews = query.filter(WorkReview.is_publish == True).limit(3)
        work_reviews_num = query.filter(WorkReview.is_publish == True).count()

    topics = user.topics.order_by(Topic.create_time.desc()).limit(3)
    topics_num = user.topics.count()

    work_images = user.work_images.order_by(
        WorkImage.create_time.desc()).limit(16)
    work_images_num = user.work_images.count()

    return render_template('user/user.html',
                           user=user,
                           work_reviews=work_reviews,
                           work_reviews_num=work_reviews_num,
                           topics=topics,
                           topics_num=topics_num,
                           work_images=work_images,
                           work_images_num=work_images_num)
Esempio n. 3
0
def user_work_reviews(user_abbr):
    user = User.query.filter(User.abbr==user_abbr).first_or_404()

    page = int(request.args.get('page', 1))
    query = user.work_reviews.order_by(WorkReview.create_time.desc())
    if check_is_me(user.id):
        pagination = query.paginate(page, 10)
    else:
        pagination = query.filter(WorkReview.is_publish==True).paginate(page, 10)

    return render_template('user/user_work_reviews.html', user=user, pagination=pagination)
Esempio n. 4
0
def user_work_reviews(user_abbr):
    user = User.query.filter(User.abbr == user_abbr).first_or_404()

    page = int(request.args.get('page', 1))
    query = user.work_reviews.order_by(WorkReview.create_time.desc())
    if check_is_me(user.id):
        pagination = query.paginate(page, 10)
    else:
        pagination = query.filter(WorkReview.is_publish == True).paginate(
            page, 10)

    return render_template('user/user_work_reviews.html',
                           user=user,
                           pagination=pagination)
Esempio n. 5
0
 def friendly_name(self):
     return '我' if check_is_me(self.id) else self.name
Esempio n. 6
0
 def friendly_name(self):
     return '我' if check_is_me(self.id) else self.name