This commit is contained in:
aaron 2026-04-11 15:18:27 +08:00
parent bbd50a38b1
commit e46dcdcd1d
7 changed files with 18 additions and 13 deletions

View File

@ -11,11 +11,11 @@ CH_JWT_SECRET=change-me-in-production
CH_JWT_EXPIRY_HOURS=72 CH_JWT_EXPIRY_HOURS=72
# Tencent COS # Tencent COS
CH_COS_SECRET_ID= CH_COS_SECRET_ID=AKIDUxR3TfeWDbqFQQDn9INJ1U8annY7TbWN
CH_COS_SECRET_KEY= CH_COS_SECRET_KEY=jJitIUTFyf5WvDPXiigS2PaaMtCJSQCn
CH_COS_REGION=ap-hongkong CH_COS_REGION=ap-guangzhou
CH_COS_BUCKET= CH_COS_BUCKET=hku-icb-1311994147
CH_COS_BASE_URL= CH_COS_BASE_URL=https://hku-icb-1311994147.cos.ap-guangzhou.myqcloud.com
# SMTP Email # SMTP Email
CH_SMTP_HOST= CH_SMTP_HOST=
@ -23,7 +23,7 @@ CH_SMTP_PORT=465
CH_SMTP_USER= CH_SMTP_USER=
CH_SMTP_PASSWORD= CH_SMTP_PASSWORD=
CH_SMTP_FROM_EMAIL= CH_SMTP_FROM_EMAIL=
CH_SMTP_FROM_NAME=ClassHub CH_SMTP_FROM_NAME=HKU ICB
# Frontend URL # Frontend URL
CH_FRONTEND_URL=http://localhost:3000 CH_FRONTEND_URL=http://localhost:3000

View File

@ -28,7 +28,7 @@ class Settings(BaseSettings):
smtp_user: str = "" smtp_user: str = ""
smtp_password: str = "" smtp_password: str = ""
smtp_from_email: str = "" smtp_from_email: str = ""
smtp_from_name: str = "ClassHub" smtp_from_name: str = "HKU ICB"
# Frontend URL # Frontend URL
frontend_url: str = "http://localhost:3000" frontend_url: str = "http://localhost:3000"

View File

@ -53,6 +53,7 @@ class User(Base):
position: Mapped[str | None] = mapped_column(String(100), nullable=True) position: Mapped[str | None] = mapped_column(String(100), nullable=True)
skills_tags: Mapped[str | None] = mapped_column(Text, nullable=True) # JSON array skills_tags: Mapped[str | None] = mapped_column(Text, nullable=True) # JSON array
wechat_id: Mapped[str | None] = mapped_column(String(100), nullable=True) wechat_id: Mapped[str | None] = mapped_column(String(100), nullable=True)
phone: Mapped[str | None] = mapped_column(String(20), nullable=True)
avatar_url: Mapped[str | None] = mapped_column(Text, nullable=True) avatar_url: Mapped[str | None] = mapped_column(Text, nullable=True)
bio: Mapped[str | None] = mapped_column(Text, nullable=True) bio: Mapped[str | None] = mapped_column(Text, nullable=True)

View File

@ -66,7 +66,7 @@ async def lifespan(app: FastAPI):
app = FastAPI( app = FastAPI(
title="ClassHub", title="HKU ICB",
description="HKU ICB Graduate Class Resource Platform", description="HKU ICB Graduate Class Resource Platform",
version="1.0.0", version="1.0.0",
lifespan=lifespan, lifespan=lifespan,
@ -74,7 +74,7 @@ app = FastAPI(
app.add_middleware( app.add_middleware(
CORSMiddleware, CORSMiddleware,
allow_origins=[settings.frontend_url, "http://localhost:3000"], allow_origins=[settings.frontend_url, "http://localhost:3000", "http://192.168.31.172:3000"],
allow_credentials=True, allow_credentials=True,
allow_methods=["*"], allow_methods=["*"],
allow_headers=["*"], allow_headers=["*"],

View File

@ -17,6 +17,7 @@ class UserOut(BaseModel):
position: str | None position: str | None
skills_tags: list[str] | None skills_tags: list[str] | None
wechat_id: str | None wechat_id: str | None
phone: str | None
avatar_url: str | None avatar_url: str | None
bio: str | None bio: str | None
created_at: datetime created_at: datetime
@ -44,6 +45,7 @@ class UserPublic(BaseModel):
position: str | None position: str | None
skills_tags: list[str] | None skills_tags: list[str] | None
wechat_id: str | None wechat_id: str | None
phone: str | None
avatar_url: str | None avatar_url: str | None
bio: str | None bio: str | None
@ -71,6 +73,7 @@ class UserUpdate(BaseModel):
position: str | None = None position: str | None = None
skills_tags: list[str] | None = None skills_tags: list[str] | None = None
wechat_id: str | None = None wechat_id: str | None = None
phone: str | None = None
bio: str | None = None bio: str | None = None

View File

@ -72,6 +72,7 @@ def user_to_public(user: User, include_contact: bool = True) -> UserPublic:
position=user.position, position=user.position,
skills_tags=user.get_skills_list(), skills_tags=user.get_skills_list(),
wechat_id=user.wechat_id if include_contact else None, wechat_id=user.wechat_id if include_contact else None,
phone=user.phone if include_contact else None,
avatar_url=user.avatar_url, avatar_url=user.avatar_url,
bio=user.bio, bio=user.bio,
) )

View File

@ -42,9 +42,9 @@ async def send_registration_notification(
html = f""" html = f"""
<h2>New Registration Pending Approval</h2> <h2>New Registration Pending Approval</h2>
<p><strong>{student_name}</strong> has registered for <strong>{class_name}</strong>.</p> <p><strong>{student_name}</strong> has registered for <strong>{class_name}</strong>.</p>
<p>Please log in to ClassHub to review and approve.</p> <p>Please log in to HKU ICB to review and approve.</p>
""" """
await send_email(admin_email, "ClassHub: New Registration", html) await send_email(admin_email, "HKU ICB: New Registration", html)
async def send_approval_notification(student_email: str, approved: bool): async def send_approval_notification(student_email: str, approved: bool):
@ -52,8 +52,8 @@ async def send_approval_notification(student_email: str, approved: bool):
html = f""" html = f"""
<h2>Registration {status_text.capitalize()}</h2> <h2>Registration {status_text.capitalize()}</h2>
<p>Your registration has been <strong>{status_text}</strong>.</p> <p>Your registration has been <strong>{status_text}</strong>.</p>
{"<p>You can now log in to ClassHub.</p>" if approved else ""} {"<p>You can now log in to HKU ICB.</p>" if approved else ""}
""" """
await send_email( await send_email(
student_email, f"ClassHub: Registration {status_text.capitalize()}", html student_email, f"HKU ICB: Registration {status_text.capitalize()}", html
) )