Overview
The Colors API provides endpoints to manage color catalog entries in the furniture store system. All color operations support CRUD functionality with logical deletion. Base URL:/colors
Endpoints
List Colors
Retrieve all active colors from the catalog.Response
Returns an HTML page with the list of colors. For API consumption, colors are represented as:Unique identifier for the color
Name of the color (max 50 characters)
Whether the color is active
ISO 8601 timestamp of creation
ISO 8601 timestamp of last update
Example Request
Example Response
Create Color
Create a new color entry in the catalog.Request Parameters
Name of the colorValidation:
- Required field
- Maximum 50 characters
- Must be unique
Response
Success:- Flash message: “Color creado exitosamente”
- Redirects to
/colors/create
Returned when a color with the same name already exists
Example Request
Error Response
Edit Color
Update an existing color in the catalog.Path Parameters
Unique identifier of the color to edit
Request Parameters
Updated name for the colorValidation:
- Required field
- Maximum 50 characters
- Must be unique
Response
Success:- Flash message: “Color actualizado exitosamente”
- Redirects to
/colors/
Returned when the color ID does not existRedirects to
/colors/ with error messageReturned when the updated name conflicts with an existing color
Returned when validation rules are violated
Example Request
Delete Color
Perform logical deletion of a color (marks as inactive).Path Parameters
Unique identifier of the color to delete
Response
Success:- Flash message: “Color eliminado exitosamente”
- Redirects to
/colors/
Returned when the color ID does not existRedirects to
/colors/ with error messageExample Request
Data Model
Color Object
Validation Rules
- name: Required, unique, max 50 characters
- active: Boolean, defaults to
true - All endpoints require CSRF token for POST requests
Error Messages
| Error | Message |
|---|---|
| Missing name | ”El nombre del color es requerido” |
| Name too long | ”El nombre no puede exceder 50 caracteres” |
| Duplicate name | ”Ya existe un color con ese nombre” |
| Not found | Color-specific error message from service |
Implementation Details
- Source:
app/catalogs/colors/routes.py:13-106 - Form:
app/catalogs/colors/forms.py:10-19 - Model:
app/models/color.py:6-61 - Pattern: Post-Redirect-Get (PRG) for all form submissions
- Deletion: Logical (soft delete) - sets
active=falseanddeleted_attimestamp