diff --git a/src/backend/app/projects/project_routes.py b/src/backend/app/projects/project_routes.py index d1f85978c0..18ccff28a6 100644 --- a/src/backend/app/projects/project_routes.py +++ b/src/backend/app/projects/project_routes.py @@ -132,7 +132,9 @@ async def read_project_summaries( total_pages = (total_projects + results_per_page - 1) // results_per_page projects = project_crud.get_project_summaries(db, user_id, skip, limit, hashtags) - project_summaries = [project_schemas.ProjectSummary.from_db_project(project) for project in projects] + project_summaries = [ + project_schemas.ProjectSummary.from_db_project(project) for project in projects + ] response = project_schemas.PaginatedProjectSummaries( results=project_summaries, diff --git a/src/backend/app/projects/project_schemas.py b/src/backend/app/projects/project_schemas.py index ed94ee7c8d..db15bc2362 100644 --- a/src/backend/app/projects/project_schemas.py +++ b/src/backend/app/projects/project_schemas.py @@ -21,10 +21,10 @@ from geojson_pydantic import Feature as GeojsonFeature from pydantic import BaseModel +from ..db import db_models from ..models.enums import ProjectPriority, ProjectStatus from ..tasks import tasks_schemas from ..users.user_schemas import User -from ..db import db_models class ODKCentral(BaseModel): @@ -78,11 +78,14 @@ class ProjectSummary(BaseModel): organisation_logo: Optional[str] = None @classmethod - def from_db_project(cls, project: db_models.DbProject,) -> "ProjectSummary": + def from_db_project( + cls, + project: db_models.DbProject, + ) -> "ProjectSummary": priority = project.priority return cls( id=project.id, - priority= priority, + priority=priority, priority_str=priority.name, title=project.title, location_str=project.location_str, @@ -97,6 +100,7 @@ def from_db_project(cls, project: db_models.DbProject,) -> "ProjectSummary": organisation_logo=project.organisation_logo, ) + class PaginationInfo(BaseModel): hasNext: bool hasPrev: bool @@ -107,10 +111,12 @@ class PaginationInfo(BaseModel): perPage: int total: int + class PaginatedProjectSummaries(BaseModel): results: List[ProjectSummary] pagination: PaginationInfo + class ProjectBase(BaseModel): id: int odkid: int