ui: 导航圆润与用户信息展示;详情页作者与关注;主页粉丝/关注与卡片网格
This commit is contained in:
@@ -1,14 +1,23 @@
|
||||
from flask import Blueprint, render_template, request, redirect, url_for
|
||||
from flask_login import login_required, current_user
|
||||
from ..extensions import db
|
||||
from ..models import User, Profile, Notification
|
||||
from ..models import User, Profile, Notification, Follow
|
||||
|
||||
bp = Blueprint("users", __name__, url_prefix="/users")
|
||||
|
||||
@bp.route("/<int:user_id>")
|
||||
def profile(user_id):
|
||||
user = User.query.get_or_404(user_id)
|
||||
return render_template("users/profile.html", user=user)
|
||||
followers_count = Follow.query.filter_by(followee_id=user.id).count()
|
||||
following_count = Follow.query.filter_by(follower_id=user.id).count()
|
||||
is_following = False
|
||||
try:
|
||||
from flask_login import current_user
|
||||
if current_user.is_authenticated:
|
||||
is_following = Follow.query.filter_by(follower_id=current_user.id, followee_id=user.id).first() is not None
|
||||
except Exception:
|
||||
pass
|
||||
return render_template("users/profile.html", user=user, followers_count=followers_count, following_count=following_count, is_following=is_following)
|
||||
|
||||
@bp.route("/me/edit", methods=["GET", "POST"])
|
||||
@login_required
|
||||
|
||||
Reference in New Issue
Block a user