feat: add maintenance tree_type with db migration and tests
- Expand ck_trees_tree_type CHECK constraint to include 'maintenance' - Add 'maintenance' to TreeType Literal in schemas - Treat maintenance trees as procedural in can_publish_tree validation - Alembic migration 0f1ca2af3647 drops and recreates the constraint - Two integration tests: create and filter by tree_type=maintenance Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -224,14 +224,14 @@ def can_publish_tree(
|
||||
errors.append({"field": "name", "message": "Tree must have a name to be published"})
|
||||
|
||||
# Validate structure based on tree type
|
||||
if tree_type == "procedural":
|
||||
if tree_type in ("procedural", "maintenance"):
|
||||
structure_valid, structure_errors = validate_procedural_structure(tree_structure)
|
||||
else:
|
||||
structure_valid, structure_errors = validate_tree_structure(tree_structure)
|
||||
errors.extend(structure_errors)
|
||||
|
||||
# Validate intake form if present (procedural only)
|
||||
if intake_form and tree_type == "procedural":
|
||||
if intake_form and tree_type in ("procedural", "maintenance"):
|
||||
form_valid, form_errors = _validate_intake_form(intake_form)
|
||||
errors.extend(form_errors)
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class Tree(Base):
|
||||
name='ck_trees_status'
|
||||
),
|
||||
CheckConstraint(
|
||||
"tree_type IN ('troubleshooting', 'procedural')",
|
||||
"tree_type IN ('troubleshooting', 'procedural', 'maintenance')",
|
||||
name='ck_trees_tree_type'
|
||||
),
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ import re
|
||||
|
||||
# --- Tree Type ---
|
||||
|
||||
TreeType = Literal['troubleshooting', 'procedural']
|
||||
TreeType = Literal['troubleshooting', 'procedural', 'maintenance']
|
||||
|
||||
# --- Intake Form Schemas ---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user