示例#1
0
def author(author_abbr):
    author = Author.query.options(db.subqueryload(Author.works)).filter(Author.abbr==author_abbr).first_or_404()
    
    if 'q' in request.args:
        quote = AuthorQuote.query.get_or_404(int(float(request.args['q'])))
    else:
        quote = author.random_quote

    stmt = db.session.query(Work.type_id, db.func.count(Work.type_id).label('type_num')).filter(Work.author_id==author.id).group_by(Work.type_id).subquery()
    work_types = db.session.query(WorkType, stmt.c.type_num).join(stmt, WorkType.id==stmt.c.type_id)

    return render_template('author/author.html', author=author, quote=quote, work_types=work_types)
示例#2
0
def author(author_abbr):
    author = Author.query.options(db.subqueryload(
        Author.works)).filter(Author.abbr == author_abbr).first_or_404()

    if 'q' in request.args:
        quote = AuthorQuote.query.get_or_404(int(float(request.args['q'])))
    else:
        quote = author.random_quote

    stmt = db.session.query(
        Work.type_id,
        db.func.count(Work.type_id).label('type_num')).filter(
            Work.author_id == author.id).group_by(Work.type_id).subquery()
    work_types = db.session.query(WorkType, stmt.c.type_num).join(
        stmt, WorkType.id == stmt.c.type_id)

    return render_template('author/author.html',
                           author=author,
                           quote=quote,
                           work_types=work_types)
示例#3
0
def admin_quotes(author_id):
    author = Author.query.options(db.subqueryload(
        Author.quotes)).get_or_404(author_id)
    return render_template('author/admin_quotes.html', author=author)
示例#4
0
def admin_quotes(author_id):
    author = Author.query.options(db.subqueryload(Author.quotes)).get_or_404(author_id)
    return render_template('author/admin_quotes.html', author=author)