refactor(http): drop categories/subcategories shim

Remove the transitional layer added in commits 1+2:

models.py
  - Drop Category, Subcategory, CreateCategory, CreateSubcategory.

crud.py
  - Drop create_category / update_category / get_category /
    get_categories / delete_category and the subcategory variants
    along with the _node_row_to_category / _node_row_to_subcategory
    helpers. Tree state is owned exclusively by menu_node CRUD now.

views_api.py
  - Remove old endpoints:
      GET    /api/v1/restaurants/{id}/categories
      POST   /api/v1/categories
      DELETE /api/v1/categories/{id}
      GET    /api/v1/categories/{id}/subcategories
      POST   /api/v1/subcategories
      DELETE /api/v1/subcategories/{id}
    Hits return 404 now.
  - GET /api/v1/restaurants/{id}/menu loses the synthetic
    'categories' projection. Response is {restaurant, tree, items}.

static/js/api.js
  - Drop listCategories / createCategory / deleteCategory and the
    subcategory wrappers.

The CMS menu builder is broken between this commit and commit 4.
The plan acknowledged this trade-off: keeping commits revertible
beats the cost of an unshipped UI page rendering a stale empty
sidebar for one commit's lifetime.
This commit is contained in:
Padreug 2026-05-02 09:08:01 +02:00
commit b7fa1aec4a
4 changed files with 8 additions and 300 deletions

View file

@ -213,46 +213,6 @@ class MenuNode(MenuNodeRow):
items: list["MenuItem"] = Field(default_factory=list)
# --------------------------------------------------------------------- #
# Transitional shims (kept until commit 3) #
# --------------------------------------------------------------------- #
# These let the old /categories and /subcategories endpoints keep
# working over the new menu_nodes table for one commit's lifetime.
# Drop in commit 3.
class CreateCategory(BaseModel):
restaurant_id: str
name: str
description: Optional[str] = None
sort_order: int = 0
image_url: Optional[str] = None
class Category(BaseModel):
id: str
restaurant_id: str
name: str
description: Optional[str] = None
sort_order: int = 0
image_url: Optional[str] = None
time: datetime
class CreateSubcategory(BaseModel):
category_id: str
name: str
sort_order: int = 0
class Subcategory(BaseModel):
id: str
category_id: str
name: str
sort_order: int = 0
time: datetime
# --------------------------------------------------------------------- #
# Menu items #
# --------------------------------------------------------------------- #