a918421945
- Remove unused imports (F401) across 17 files - Fix f-strings without placeholders (F541) in 3 files - Add noqa: E712 to SQLAlchemy == True comparisons (valid ORM pattern) - Preserve alembic side-effect import with noqa: F401 Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> Agent-Logs-Url: https://github.com/christianlouis/pop_puller_to_gmail/sessions/99c3a25f-3479-473d-ac95-9faaa0ddd55b
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""Subscription and payment endpoints"""
|
|
|
|
from typing import List
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from sqlalchemy import select
|
|
|
|
from app.core.database import get_db
|
|
from app.core.deps import get_current_active_user
|
|
from app.models.database_models import User, SubscriptionPlan
|
|
from app.models.schemas import SubscriptionPlanResponse
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/plans", response_model=List[SubscriptionPlanResponse])
|
|
async def list_subscription_plans(db: AsyncSession = Depends(get_db)):
|
|
"""List all available subscription plans"""
|
|
result = await db.execute(
|
|
select(SubscriptionPlan).where(SubscriptionPlan.is_active == True) # noqa: E712
|
|
)
|
|
return result.scalars().all()
|
|
|
|
|
|
@router.get("/current")
|
|
async def get_current_subscription(
|
|
current_user: User = Depends(get_current_active_user),
|
|
):
|
|
"""Get current user's subscription details"""
|
|
return {
|
|
"tier": current_user.subscription_tier,
|
|
"status": current_user.subscription_status,
|
|
"expires_at": current_user.subscription_expires_at,
|
|
}
|