diff --git a/api/v1/routes/organisation.py b/api/v1/routes/organisation.py index ec66b3939..a41d159d8 100644 --- a/api/v1/routes/organisation.py +++ b/api/v1/routes/organisation.py @@ -3,7 +3,6 @@ from fastapi.encoders import jsonable_encoder from fastapi.responses import StreamingResponse from sqlalchemy.orm import Session - from api.utils.success_response import success_response from api.v1.models.user import User from api.v1.schemas.organisation import ( @@ -126,4 +125,4 @@ async def delete_organisation( return success_response( status_code=status.HTTP_200_OK, message="Organisation with ID {org_id} deleted successfully", - ) + ) \ No newline at end of file diff --git a/api/v1/routes/product.py b/api/v1/routes/product.py index cde3239a8..fe8c2a941 100644 --- a/api/v1/routes/product.py +++ b/api/v1/routes/product.py @@ -265,31 +265,10 @@ def get_organisation_products( db, user=current_user, org_id=org_id, limit=limit, page=page ) - total_products = len(products) - - total_pages = int(total_products / limit) + (total_products % limit > 0) - - product_data = [ - { - "name": product.name, - "description": product.description, - "price": str(product.price), - } - for product in products - ] - - data = { - "current_page": page, - "total_pages": total_pages, - "limit": limit, - "total_items": total_products, - "products": product_data, - } - return success_response( status_code=200, message="Successfully fetched organisations products", - data=data, + data=[jsonable_encoder(product) for product in products], ) diff --git a/api/v1/services/invite.py b/api/v1/services/invite.py index b78546f45..45a818de9 100644 --- a/api/v1/services/invite.py +++ b/api/v1/services/invite.py @@ -9,6 +9,7 @@ from api.v1.models.invitation import Invitation from api.v1.models.organisation import Organisation from api.v1.models.user import User +from api.v1.services.user import user_service from sqlalchemy.exc import IntegrityError from api.v1.models.permissions.role import Role from api.v1.schemas.permissions.roles import RoleCreate @@ -214,7 +215,6 @@ def fetch(self): def fetch_all(self): pass - def update(self): pass diff --git a/api/v1/services/product.py b/api/v1/services/product.py index a52ea6a4f..61cce2f3a 100644 --- a/api/v1/services/product.py +++ b/api/v1/services/product.py @@ -252,6 +252,7 @@ def fetch_all(db: Session, **query_params: Optional[Any]): ) return query.all() - - + + + product_service = ProductService()