Python app.models.Follow() Examples
The following are 6
code examples of app.models.Follow().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
app.models
, or try the search function
.
Example #1
Source File: manage.py From circleci-demo-python-flask with MIT License | 5 votes |
def make_shell_context(): return dict(app=app, db=db, User=User, Follow=Follow, Role=Role, Permission=Permission, Post=Post, Comment=Comment)
Example #2
Source File: manage.py From Simpleblog with MIT License | 5 votes |
def make_shell_context(): return dict(app=app, db=db, User=User, Role=Role, Post=Post, \ Follow=Follow, Permission=Permission, Admin=Admin)
Example #3
Source File: manage.py From flasky-first-edition with MIT License | 5 votes |
def make_shell_context(): return dict(app=app, db=db, User=User, Follow=Follow, Role=Role, Permission=Permission, Post=Post, Comment=Comment)
Example #4
Source File: manage.py From flasky-with-celery with MIT License | 5 votes |
def make_shell_context(): return dict(app=app, db=db, User=User, Follow=Follow, Role=Role, Permission=Permission, Post=Post, Comment=Comment)
Example #5
Source File: views.py From flask-blog with MIT License | 5 votes |
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')
Example #6
Source File: views.py From flask-blog with MIT License | 4 votes |
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)