File size: 627 Bytes
9bed109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from __future__ import annotations

from uuid import UUID

from fastapi import HTTPException, status
from shared.schemas.project import Project

from backend.db.base import ContentStore


def project_readable_by_user(
    store: ContentStore,
    project_id: UUID,
    user_id: UUID,
) -> Project:
    """Return the project if it exists and is owned by user_id; otherwise 404."""
    project = store.get_project(project_id)
    if project is None or project.user_id != user_id:
        raise HTTPException(
            status_code=status.HTTP_404_NOT_FOUND,
            detail="Project not found",
        )
    return project