Example #1
0
def art_by_cate():
    id = request.form.get('id')
    cate = Category.query.filter(Category.id == id).first()
    users = all_user()
    articles = Article.query.filter(Article.cate_id == id).all()
    return render_template('art_by_cate.html',
                           articles=articles,
                           users=users,
                           cate=cate)
Example #2
0
def mar_comment():
    if account() < 0:
        id = request.args.get('id')
        art_name = Article.query.filter(Article.id == id).first().art_name
        comments = Comment.query.filter(Comment.art_id == id).all()
        users = all_user()
        return render_template('admin/comment.html',
                               comments=comments,
                               art_name=art_name,
                               users=users)
    else:
        return redirect(url_for('login'))
Example #3
0
def article():
    if account() < 0:
        categories = all_cate()
        articles = all_art()
        users = all_user()
        for art in articles:
            for cate in categories:
                if art.cate_id == cate.id:
                    art.cate_name = cate.cate_name
        return render_template('admin/article.html',
                               articles=articles,
                               users=users)
    else:
        return redirect(url_for('login'))
Example #4
0
def comment():
    if request.method == 'GET':
        id = request.args.get('id')
        users = all_user()
        comments = Comment.query.filter(Comment.art_id == id).all()
        return render_template('comment.html', comments=comments, users=users)
    else:
        if account() < 0:
            id = request.form.get('id')
            content = request.form.get('content')
            comment = Comment(art_id=id,
                              content=content,
                              user=session.get('user_id'))
            db.session.add(comment)
            db.session.commit()
            return 'ok'
        else:
            return 'error'
Example #5
0
def mar_user():
    if account() < 0:
        users = all_user()
        return render_template('admin/user.html', users=users)
    else:
        return redirect(url_for('login'))