diff --git a/backend/alembic/versions/007_shopping_list_type_and_item_enrichment.py b/backend/alembic/versions/007_shopping_list_type_and_item_enrichment.py
new file mode 100644
index 0000000..c843130
--- /dev/null
+++ b/backend/alembic/versions/007_shopping_list_type_and_item_enrichment.py
@@ -0,0 +1,32 @@
+"""007 - list_type sur shopping.lists, url/description/image_url sur list_items
+
+Revision ID: 007
+Revises: 006
+Create Date: 2026-05-30
+"""
+
+from alembic import op
+import sqlalchemy as sa
+
+revision = '007'
+down_revision = '006'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ op.add_column(
+ 'lists',
+ sa.Column('list_type', sa.String(20), nullable=False, server_default='weekly'),
+ schema='shopping',
+ )
+ op.add_column('list_items', sa.Column('url', sa.Text, nullable=True), schema='shopping')
+ op.add_column('list_items', sa.Column('description', sa.Text, nullable=True), schema='shopping')
+ op.add_column('list_items', sa.Column('image_url', sa.String(255), nullable=True), schema='shopping')
+
+
+def downgrade():
+ op.drop_column('list_items', 'image_url', schema='shopping')
+ op.drop_column('list_items', 'description', schema='shopping')
+ op.drop_column('list_items', 'url', schema='shopping')
+ op.drop_column('lists', 'list_type', schema='shopping')
diff --git a/backend/app/api/shopping.py b/backend/app/api/shopping.py
index 919c3b5..a7302ad 100644
--- a/backend/app/api/shopping.py
+++ b/backend/app/api/shopping.py
@@ -27,6 +27,19 @@ def _iso_week_label() -> str:
return f"S{iso[1]} {iso[0]}"
+async def _unique_week_label(session: AsyncSession) -> str:
+ base = _iso_week_label()
+ existing = (await session.execute(
+ select(ShoppingList.name).where(ShoppingList.name.like(f"{base}%"))
+ )).scalars().all()
+ if base not in existing:
+ return base
+ counter = 2
+ while f"{base} ({counter})" in existing:
+ counter += 1
+ return f"{base} ({counter})"
+
+
def _item_to_response(item: ListItem) -> ListItemResponse:
display_name = item.custom_name or (item.product.name if item.product else "Article inconnu")
return ListItemResponse(
@@ -40,6 +53,9 @@ def _item_to_response(item: ListItem) -> ListItemResponse:
price_recorded=item.price_recorded,
carried_over=item.carried_over,
sort_order=item.sort_order,
+ url=item.url,
+ description=item.description,
+ image_url=item.image_url,
)
@@ -48,6 +64,7 @@ def _list_to_response(lst: ShoppingList) -> ShoppingListResponse:
return ShoppingListResponse(
id=lst.id,
name=lst.name,
+ list_type=lst.list_type,
store_id=lst.store_id,
week_date=lst.week_date,
status=lst.status,
@@ -167,8 +184,8 @@ async def create_shopping_list(
session: AsyncSession = Depends(get_session),
):
data = payload.model_dump()
- if not data.get('name'):
- data['name'] = _iso_week_label()
+ if not data.get('name') and data.get('list_type', 'weekly') == 'weekly':
+ data['name'] = await _unique_week_label(session)
lst = ShoppingList(**data)
session.add(lst)
await session.commit()
@@ -380,7 +397,7 @@ async def generate_magic_list(session: AsyncSession = Depends(get_session)):
result = await session.execute(query)
rows = result.mappings().all()
- new_list = ShoppingList(name=_iso_week_label(), status="draft")
+ new_list = ShoppingList(name=await _unique_week_label(session), list_type="weekly", status="draft")
session.add(new_list)
await session.flush()
@@ -425,8 +442,13 @@ async def finish_shopping(list_id: uuid.UUID, session: AsyncSession = Depends(ge
lst.status = "done"
unchecked = [i for i in lst.items if not i.is_checked]
- if unchecked:
- new_list = ShoppingList(store_id=lst.store_id, status="draft", name=_iso_week_label())
+ if unchecked and lst.list_type == 'weekly':
+ new_list = ShoppingList(
+ store_id=lst.store_id,
+ list_type="weekly",
+ status="draft",
+ name=await _unique_week_label(session),
+ )
session.add(new_list)
await session.flush()
for item in unchecked:
diff --git a/backend/app/models/shopping.py b/backend/app/models/shopping.py
index b91ea69..220c573 100644
--- a/backend/app/models/shopping.py
+++ b/backend/app/models/shopping.py
@@ -63,6 +63,7 @@ class ShoppingList(Base):
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
name: Mapped[str | None] = mapped_column(String(100))
+ list_type: Mapped[str] = mapped_column(String(20), server_default="weekly")
store_id: Mapped[uuid.UUID | None] = mapped_column(UUID(as_uuid=True), ForeignKey("shopping.stores.id", ondelete="SET NULL"))
week_date: Mapped[date | None] = mapped_column(Date)
status: Mapped[str] = mapped_column(String(20), server_default="draft")
@@ -86,6 +87,9 @@ class ListItem(Base):
price_recorded: Mapped[Decimal | None] = mapped_column(Numeric(8, 2))
carried_over: Mapped[bool] = mapped_column(Boolean, server_default=text("false"))
sort_order: Mapped[int | None] = mapped_column(Integer)
+ url: Mapped[str | None] = mapped_column(Text)
+ description: Mapped[str | None] = mapped_column(Text)
+ image_url: Mapped[str | None] = mapped_column(String(255))
shopping_list: Mapped["ShoppingList"] = relationship("ShoppingList", back_populates="items")
product: Mapped["Product | None"] = relationship("Product", lazy="select")
diff --git a/backend/app/schemas/shopping.py b/backend/app/schemas/shopping.py
index 73c5a79..8d3a526 100644
--- a/backend/app/schemas/shopping.py
+++ b/backend/app/schemas/shopping.py
@@ -83,6 +83,9 @@ class ListItemCreate(BaseModel):
custom_name: str | None = None
quantity: Decimal | None = None
unit: str | None = None
+ url: str | None = None
+ description: str | None = None
+ image_url: str | None = None
@model_validator(mode='after')
def must_have_name(self) -> 'ListItemCreate':
@@ -96,6 +99,9 @@ class ListItemUpdate(BaseModel):
quantity: Decimal | None = None
unit: str | None = None
price_recorded: Decimal | None = None
+ url: str | None = None
+ description: str | None = None
+ image_url: str | None = None
class ListItemResponse(BaseModel):
@@ -110,13 +116,23 @@ class ListItemResponse(BaseModel):
price_recorded: Decimal | None
carried_over: bool
sort_order: int | None
+ url: str | None
+ description: str | None
+ image_url: str | None
class ShoppingListCreate(BaseModel):
name: str | None = None
+ list_type: Literal['weekly', 'project'] = 'weekly'
store_id: uuid.UUID | None = None
week_date: date | None = None
+ @model_validator(mode='after')
+ def project_requires_name(self) -> 'ShoppingListCreate':
+ if self.list_type == 'project' and not self.name:
+ raise ValueError('Une liste projet doit avoir un nom')
+ return self
+
class ShoppingListUpdate(BaseModel):
name: str | None = None
@@ -128,6 +144,7 @@ class ShoppingListResponse(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: uuid.UUID
name: str | None
+ list_type: str
store_id: uuid.UUID | None
week_date: date | None
status: str
@@ -140,6 +157,7 @@ class ShoppingListDetailResponse(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: uuid.UUID
name: str | None
+ list_type: str
store_id: uuid.UUID | None
week_date: date | None
status: str
diff --git a/frontend/package.json b/frontend/package.json
index aee9085..d4869ed 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -1,7 +1,7 @@
{
"name": "homehub-frontend",
"private": true,
- "version": "0.5.13",
+ "version": "0.5.14",
"type": "module",
"scripts": {
"dev": "vite",
diff --git a/frontend/src/api/shopping.ts b/frontend/src/api/shopping.ts
index ac003f9..3542c16 100644
--- a/frontend/src/api/shopping.ts
+++ b/frontend/src/api/shopping.ts
@@ -82,11 +82,15 @@ export interface ShoppingItem {
price_recorded: string | null
carried_over: boolean
sort_order: number | null
+ url: string | null
+ description: string | null
+ image_url: string | null
}
export interface ShoppingList {
id: string
name: string | null
+ list_type: 'weekly' | 'project'
store_id: string | null
week_date: string | null
status: 'draft' | 'active' | 'done'
@@ -101,6 +105,7 @@ export interface ShoppingListDetail extends ShoppingList {
export interface ShoppingListCreate {
name?: string
+ list_type?: 'weekly' | 'project'
store_id?: string
week_date?: string
}
@@ -116,6 +121,9 @@ export interface ShoppingItemCreate {
custom_name?: string
quantity?: string
unit?: string
+ url?: string
+ description?: string
+ image_url?: string
}
export interface ShoppingItemUpdate {
@@ -123,6 +131,9 @@ export interface ShoppingItemUpdate {
quantity?: string
unit?: string
price_recorded?: string
+ url?: string
+ description?: string
+ image_url?: string
}
const BASE = '/api/shopping'
@@ -201,6 +212,10 @@ export async function createList(data: ShoppingListCreate): Promise
+ {item.description}
+ Aucun projet en cours setImgError(true)}
+ style={{ width: '100%', height: '100%', objectFit: 'cover' }}
+ />
+
+
{hasCurrentList ? (currentList.name ?? 'Courses') : 'Courses'}
+ {isProjectList && (
+
+ PROJET
+
+ )}
- {hasCurrentList && (
+ {hasCurrentList && !isProjectList && (
Article
)}
+ {hasCurrentList && isProjectList && (
+
+ )}
{/* ── Erreur ── */}
@@ -520,6 +619,38 @@ export default function ShoppingPage() {
}}
>Voir l'historique ({pastLists.length})
)}
+
+ {/* Séparateur + listes projet */}
+
+