From 065779d9b1e825d74f6216c1f9c97150e23fb0cc Mon Sep 17 00:00:00 2001 From: Niraj Adhikari Date: Fri, 25 Aug 2023 14:28:50 +0545 Subject: [PATCH 1/2] updated json format in error message in validate form --- src/backend/app/central/central_crud.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/backend/app/central/central_crud.py b/src/backend/app/central/central_crud.py index 9fdec47cfb..02e4ef25a3 100644 --- a/src/backend/app/central/central_crud.py +++ b/src/backend/app/central/central_crud.py @@ -32,6 +32,7 @@ from osm_fieldwork.OdkCentral import OdkAppUser, OdkForm, OdkProject from pyxform.xls2xform import xls2xform_convert from sqlalchemy.orm import Session +from fastapi.responses import JSONResponse from ..config import settings from ..db import db_models @@ -365,10 +366,7 @@ async def test_form_validity(xform_content: str, form_type: str): xls2xform_convert(xlsform_path=xlsform_path, xform_path=outfile, validate=False) return {"message": "Your form is valid"} except Exception as e: - raise HTTPException( - status_code=400, - detail={"message": "Your form is invalid", "possible_reason": str(e)}, - ) + return JSONResponse(content={"message":"Your form is invalid", "possible_reason":str(e)}, status_code=400) def generate_updated_xform( From 4bd2abe554adae3287f9f3fa59d7fbf3cb09de57 Mon Sep 17 00:00:00 2001 From: Niraj Adhikari Date: Fri, 25 Aug 2023 14:30:20 +0545 Subject: [PATCH 2/2] added organisation logo in summary api --- src/backend/app/projects/project_crud.py | 1 + src/backend/app/projects/project_schemas.py | 1 + 2 files changed, 2 insertions(+) diff --git a/src/backend/app/projects/project_crud.py b/src/backend/app/projects/project_crud.py index ad90019930..4d8dbfdc77 100644 --- a/src/backend/app/projects/project_crud.py +++ b/src/backend/app/projects/project_crud.py @@ -1733,6 +1733,7 @@ def convert_to_project_summary(db_project: db_models.DbProject): summary.num_contributors = ( db_project.tasks_mapped + db_project.tasks_validated ) # TODO: get real number of contributors + summary.organisation_logo = db_project.organisation.logo if db_project.organisation else None return summary else: diff --git a/src/backend/app/projects/project_schemas.py b/src/backend/app/projects/project_schemas.py index 9ace427c8f..c82d527ba7 100644 --- a/src/backend/app/projects/project_schemas.py +++ b/src/backend/app/projects/project_schemas.py @@ -75,6 +75,7 @@ class ProjectSummary(BaseModel): tasks_bad: int = None hashtags: List[str] = None organisation_id: int = None + organisation_logo: str = None class Config: orm_mode = True