mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-01-10 11:01:21 -05:00
feat: Shopping List Item Pagination Route (#2145)
* added pagination route for list items * pytest
This commit is contained in:
@@ -12,6 +12,7 @@ from mealie.schema.group.group_shopping_list import (
|
||||
ShoppingListCreate,
|
||||
ShoppingListItemCreate,
|
||||
ShoppingListItemOut,
|
||||
ShoppingListItemPagination,
|
||||
ShoppingListItemsCollectionOut,
|
||||
ShoppingListItemUpdate,
|
||||
ShoppingListItemUpdateBulk,
|
||||
@@ -101,6 +102,12 @@ class ShoppingListItemController(BaseCrudController):
|
||||
self.logger,
|
||||
)
|
||||
|
||||
@item_router.get("", response_model=ShoppingListItemPagination)
|
||||
def get_all(self, q: PaginationQuery = Depends()):
|
||||
response = self.repo.page_all(pagination=q, override=ShoppingListItemOut)
|
||||
response.set_pagination_guides(router.url_path_for("get_all"), q.dict())
|
||||
return response
|
||||
|
||||
@item_router.post("/create-bulk", response_model=ShoppingListItemsCollectionOut, status_code=201)
|
||||
def create_many(self, data: list[ShoppingListItemCreate]):
|
||||
items = self.service.bulk_create_items(data)
|
||||
|
||||
@@ -177,6 +177,10 @@ class ShoppingListItemsCollectionOut(MealieModel):
|
||||
deleted_items: list[ShoppingListItemOut] = []
|
||||
|
||||
|
||||
class ShoppingListItemPagination(PaginationBase):
|
||||
items: list[ShoppingListItemOut]
|
||||
|
||||
|
||||
class ShoppingListCreate(MealieModel):
|
||||
name: str | None = None
|
||||
extras: dict | None = {}
|
||||
|
||||
Reference in New Issue
Block a user