Remove avconnect_macro_id field from user response schema for /api/gates
This commit is contained in:
@@ -66,6 +66,7 @@ def keypass_to_response(kp: Keypass) -> KeypassResponse:
|
|||||||
# ── Gates ─────────────────────────────────────────────────────────────────────
|
# ── Gates ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
class GateResponse(BaseModel):
|
class GateResponse(BaseModel):
|
||||||
|
"""Full gate response — admin use only."""
|
||||||
model_config = ConfigDict(from_attributes=True)
|
model_config = ConfigDict(from_attributes=True)
|
||||||
id: int
|
id: int
|
||||||
name: str
|
name: str
|
||||||
@@ -75,6 +76,15 @@ class GateResponse(BaseModel):
|
|||||||
group_name: Optional[str] = None
|
group_name: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
|
class GatePublicResponse(BaseModel):
|
||||||
|
"""Gate response for keypass users — no internal fields."""
|
||||||
|
model_config = ConfigDict(from_attributes=True)
|
||||||
|
id: int
|
||||||
|
name: str
|
||||||
|
gate_type: str
|
||||||
|
group_name: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
class GateCreate(BaseModel):
|
class GateCreate(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
gate_type: str # 'car' | 'pedestrian'
|
gate_type: str # 'car' | 'pedestrian'
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from sqlalchemy.orm import Session
|
|||||||
from core.auth import decrypt_secret
|
from core.auth import decrypt_secret
|
||||||
from core.database import ApiCredential, GateAccessLog, GateDB, Keypass, get_db
|
from core.database import ApiCredential, GateAccessLog, GateDB, Keypass, get_db
|
||||||
from core.dependencies import require_admin, require_manager, require_keypass
|
from core.dependencies import require_admin, require_manager, require_keypass
|
||||||
from core.schemas import GateCreate, GateResponse
|
from core.schemas import GateCreate, GatePublicResponse, GateResponse
|
||||||
from services.gates import call_open_gate
|
from services.gates import call_open_gate
|
||||||
|
|
||||||
router = APIRouter(tags=["gates"])
|
router = APIRouter(tags=["gates"])
|
||||||
@@ -119,7 +119,7 @@ async def admin_open_gate(
|
|||||||
|
|
||||||
# ── User-facing gate routes ───────────────────────────────────────────────────
|
# ── User-facing gate routes ───────────────────────────────────────────────────
|
||||||
|
|
||||||
@router.get("/api/gates", response_model=list[GateResponse])
|
@router.get("/api/gates", response_model=list[GatePublicResponse])
|
||||||
async def list_gates(
|
async def list_gates(
|
||||||
db: Session = Depends(get_db), _kp: Keypass = Depends(require_keypass)
|
db: Session = Depends(get_db), _kp: Keypass = Depends(require_keypass)
|
||||||
):
|
):
|
||||||
|
|||||||
Reference in New Issue
Block a user