feat: 初始版本,圆角主题与首次管理员引导

This commit is contained in:
2025-12-07 10:53:52 +08:00
commit 63db6a0815
43 changed files with 1293 additions and 0 deletions

25
app/blueprints/follows.py Normal file
View File

@@ -0,0 +1,25 @@
from flask import Blueprint, redirect, url_for
from flask_login import login_required, current_user
from ..extensions import db
from ..models import Follow, User
bp = Blueprint("follows", __name__, url_prefix="/follows")
@bp.route("/follow/<int:user_id>")
@login_required
def follow(user_id):
target = User.query.get_or_404(user_id)
if target.id != current_user.id:
exist = Follow.query.filter_by(follower_id=current_user.id, followee_id=target.id).first()
if not exist:
db.session.add(Follow(follower_id=current_user.id, followee_id=target.id))
db.session.commit()
return redirect(url_for("users.profile", user_id=target.id))
@bp.route("/unfollow/<int:user_id>")
@login_required
def unfollow(user_id):
target = User.query.get_or_404(user_id)
Follow.query.filter_by(follower_id=current_user.id, followee_id=target.id).delete()
db.session.commit()
return redirect(url_for("users.profile", user_id=target.id))