# -*- coding: utf-8 -*-
"""
    :author: <NAME> (徐天明)
    :url: http://greyli.com
    :copyright: © 2021 <NAME> <<EMAIL>>
    :license: MIT, see LICENSE for more details.
"""
from flask import render_template, current_app, request, Blueprint

from albumy.models import User, Photo

user_bp = Blueprint('user', __name__)


@user_bp.route('/<username>')
def index(username):
    user = User.query.filter_by(username=username).first_or_404()
    page = request.args.get('page', 1, type=int)
    per_page = current_app.config['ALBUMY_PHOTO_PER_PAGE']
    pagination = Photo.query.with_parent(user).order_by(Photo.timestamp.desc()).paginate(page, per_page)
    photos = pagination.items
    return render_template('user/index.html', user=user, pagination=pagination, photos=photos)

# -*- coding: utf-8 -*-
"""
    :author: <NAME> (徐天明)
    :url: http://greyli.com
    :copyright: © 2021 <NAME> <<EMAIL>>
    :license: MIT, see LICENSE for more details.
"""
from flask import render_template, current_app, request, Blueprint

from albumy.models import User, Photo

user_bp = Blueprint('user', __name__)


@user_bp.route('/<username>')
def index(username):
    user = User.query.filter_by(username=username).first_or_404()
    page = request.args.get('page', 1, type=int)
    per_page = current_app.config['ALBUMY_PHOTO_PER_PAGE']
    pagination = Photo.query.with_parent(user).order_by(Photo.timestamp.desc()).paginate(page, per_page)
    photos = pagination.items
    return render_template('user/index.html', user=user, pagination=pagination, photos=photos)

# -*- coding: utf-8 -*- :author: <NAME> (徐天明)     :url: http://greyli.com     :copyright: © 2021 <NAME> <<EMAIL>>     :license: MIT, see LICENSE for more details.