當前位置: 首頁>>代碼示例>>Python>>正文


Python models.Follow方法代碼示例

本文整理匯總了Python中app.models.Follow方法的典型用法代碼示例。如果您正苦於以下問題:Python models.Follow方法的具體用法?Python models.Follow怎麽用?Python models.Follow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app.models的用法示例。


在下文中一共展示了models.Follow方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: make_shell_context

# 需要導入模塊: from app import models [as 別名]
# 或者: from app.models import Follow [as 別名]
def make_shell_context():
    return dict(app=app, db=db, User=User, Follow=Follow, Role=Role,
                Permission=Permission, Post=Post, Comment=Comment) 
開發者ID:CircleCI-Public,項目名稱:circleci-demo-python-flask,代碼行數:5,代碼來源:manage.py

示例2: make_shell_context

# 需要導入模塊: from app import models [as 別名]
# 或者: from app.models import Follow [as 別名]
def make_shell_context():
    return dict(app=app, db=db, User=User, Role=Role, Post=Post, \
                Follow=Follow, Permission=Permission, Admin=Admin) 
開發者ID:Blackyukun,項目名稱:Simpleblog,代碼行數:5,代碼來源:manage.py

示例3: contact

# 需要導入模塊: from app import models [as 別名]
# 或者: from app.models import Follow [as 別名]
def contact():
    form = CommentForm(request.form, follow_id=-1)
    if form.validate_on_submit():
        followed_id = int(form.follow_id.data if form.follow_id.data else -1)
        reply_to = form.follow.data
        content = form.content.data
        if reply_to:
            content = form.content.data.replace("@" + reply_to + " ", "")
        comment = Comment(content=content,
                          author_name=form.name.data,
                          author_email=form.email.data,
                          comment_type='contact')
        db.session.add(comment)
        db.session.commit()

        if followed_id != -1:
            followed = Comment.query.get_or_404(followed_id)
            f = Follow(follower=comment, followed=followed)
            comment.comment_type = 'reply'
            # comment.reply_to = followed.author_name
            comment.reply_to = reply_to if reply_to else followed.author_name
            db.session.add(f)
            db.session.add(comment)
            db.session.commit()
        # flash(u'提交評論成功!', 'success')
        return redirect(url_for('.contact', page=-1))
    page = request.args.get('page', 1, type=int)
    _query = Comment.query.filter_by(comment_type='contact')
    counts = _query.count()
    if page == -1:
        page = int((counts - 1) / Comment.PER_PAGE + 1)
    pagination = _query.order_by(Comment.created.asc()).paginate(
        page, per_page=Comment.PER_PAGE,
        error_out=False)
    comments = pagination.items
    return render_template('contact.html', comments=comments, counts=counts, pagination=pagination, form=form,
                           endpoint='.contact') 
開發者ID:adisonhuang,項目名稱:flask-blog,代碼行數:39,代碼來源:views.py

示例4: article

# 需要導入模塊: from app import models [as 別名]
# 或者: from app.models import Follow [as 別名]
def article(id):
    article = Article.query.get_or_404(id)
    if not article.published:
        abort(403)
    next = next_article(article)
    prev = prev_article(article)
    form = CommentForm(request.form, follow_id=-1)
    if form.validate_on_submit():
        followed_id = int(form.follow_id.data if form.follow_id.data else -1)
        reply_to = form.follow.data
        content = form.content.data
        if reply_to:
            content = form.content.data.replace("@" + reply_to + " ", "")
        comment = Comment(article=article,
                          content=content,
                          author_name=form.name.data,
                          author_email=form.email.data)
        db.session.add(comment)
        db.session.commit()

        if followed_id != -1:
            followed = Comment.query.get_or_404(followed_id)
            f = Follow(follower=comment, followed=followed)
            comment.comment_type = 'reply'
            # comment.reply_to = followed.author_name
            comment.reply_to = reply_to if reply_to else followed.author_name
            db.session.add(f)
            db.session.add(comment)
            db.session.commit()
        # flash(u'提交評論成功!', 'success')
        return redirect(url_for('.article', id=article.id, page=-1))
    # if form.errors:
    # flash(u'發表評論失敗', 'danger')

    page = request.args.get('page', 1, type=int)
    counts = article.comments.count()
    if page == -1:
        page = int((counts - 1) / Comment.PER_PAGE + 1)
    pagination = article.comments.order_by(Comment.created.asc()).paginate(
        page, per_page=Comment.PER_PAGE,
        error_out=False)
    comments = pagination.items

    return render_template('article.html', article=article, category_id=article.category_id, next_article=next,
                           prev_article=prev, comments=comments, counts=counts, pagination=pagination, form=form,
                           endpoint='.article', id=article.id) 
開發者ID:adisonhuang,項目名稱:flask-blog,代碼行數:48,代碼來源:views.py


注:本文中的app.models.Follow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。