updated admin page with more functionality, simplified burger menu and added many-to-many parent-child relationship
Build and Push Docker Image / build-and-push (pull_request) Successful in 59s
Python Code Quality / python-code-quality (pull_request) Successful in 10s
Python Test / python-test (pull_request) Successful in 17s

This commit is contained in:
Brian Bjarke Jensen
2025-11-10 22:58:52 +01:00
parent df28af880a
commit 402b5898bb
26 changed files with 952 additions and 564 deletions
+5 -15
View File
@@ -19,6 +19,7 @@ from baby_monitor.repositories.child.sqlite_child import SQLiteChildRepository
from baby_monitor.repositories.dependencies.get_child_repository import (
get_child_repository,
)
from baby_monitor.utils.access_control import verify_child_access
router = APIRouter(prefix="/api/feedings", tags=["feedings"])
@@ -32,12 +33,7 @@ def create_feeding(
) -> FeedingResponse:
"""Create a new feeding log entry."""
# Verify the child belongs to the authenticated user
child = child_repo.get_by_id(request.child_id)
if not child:
raise HTTPException(status_code=404, detail="Child not found")
if child["user_id"] != user_id:
raise HTTPException(status_code=403, detail="Access denied to this child")
verify_child_access(child_repo, request.child_id, user_id)
feeding = feeding_repo.create(
child_id=request.child_id,
@@ -95,9 +91,7 @@ def get_feeding(
raise HTTPException(status_code=404, detail="Feeding log not found")
# Verify the feeding belongs to user's child
child = child_repo.get_by_id(feeding["child_id"])
if not child or child["user_id"] != user_id:
raise HTTPException(status_code=403, detail="Access denied")
verify_child_access(child_repo, feeding["child_id"], user_id)
return FeedingResponse(**feeding)
@@ -117,9 +111,7 @@ def update_feeding(
raise HTTPException(status_code=404, detail="Feeding log not found")
# Verify ownership
child = child_repo.get_by_id(feeding["child_id"])
if not child or child["user_id"] != user_id:
raise HTTPException(status_code=403, detail="Access denied")
verify_child_access(child_repo, feeding["child_id"], user_id)
# Update the feeding
updated_feeding = feeding_repo.update(
@@ -149,9 +141,7 @@ def delete_feeding(
raise HTTPException(status_code=404, detail="Feeding log not found")
# Verify ownership
child = child_repo.get_by_id(feeding["child_id"])
if not child or child["user_id"] != user_id:
raise HTTPException(status_code=403, detail="Access denied")
verify_child_access(child_repo, feeding["child_id"], user_id)
success = feeding_repo.delete(feeding_id)
if not success: