feat: 初始版本,圆角主题与首次管理员引导
This commit is contained in:
23
app/blueprints/feed.py
Normal file
23
app/blueprints/feed.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from flask import Blueprint, render_template
|
||||
from flask_login import login_required, current_user
|
||||
from sqlalchemy import desc
|
||||
from ..models import Post, Visibility, ReviewStatus, Follow
|
||||
|
||||
bp = Blueprint("feed", __name__, url_prefix="/feed")
|
||||
|
||||
@bp.route("/")
|
||||
def home():
|
||||
return discover()
|
||||
|
||||
@bp.route("/discover")
|
||||
def discover():
|
||||
posts = Post.query.filter(Post.visibility == Visibility.public, Post.status == ReviewStatus.approved).order_by(desc(Post.published_at)).limit(100).all()
|
||||
return render_template("feed/discover.html", posts=posts)
|
||||
|
||||
@bp.route("/following")
|
||||
@login_required
|
||||
def following():
|
||||
ids = [f.followee_id for f in Follow.query.filter_by(follower_id=current_user.id).all()]
|
||||
q = Post.query.filter(Post.user_id.in_(ids)).filter((Post.visibility == Visibility.followers) | (Post.visibility == Visibility.public))
|
||||
posts = q.order_by(desc(Post.created_at)).limit(100).all()
|
||||
return render_template("feed/following.html", posts=posts)
|
||||
Reference in New Issue
Block a user