Skip to content

Commit

Permalink
Merge pull request #895 from marveldo/feat/restructure-products
Browse files Browse the repository at this point in the history
bug fix : Fixed and restructured the products endpoint to work on the frontend
  • Loading branch information
CodewithSegNet authored Aug 15, 2024
2 parents 40b9884 + e6d302e commit 72aee10
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 27 deletions.
3 changes: 1 addition & 2 deletions api/v1/routes/organisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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",
)
)
23 changes: 1 addition & 22 deletions api/v1/routes/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)


Expand Down
2 changes: 1 addition & 1 deletion api/v1/services/invite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -214,7 +215,6 @@ def fetch(self):

def fetch_all(self):
pass

def update(self):
pass

Expand Down
5 changes: 3 additions & 2 deletions api/v1/services/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def fetch_all(db: Session, **query_params: Optional[Any]):
)

return query.all()





product_service = ProductService()

0 comments on commit 72aee10

Please sign in to comment.