Bugfixes in dashboard and calendar
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"""HTTP routes for planned leave days (calendar planning)."""
|
||||
|
||||
from datetime import date
|
||||
from uuid import UUID
|
||||
|
||||
from fastapi import APIRouter, HTTPException, Query, status
|
||||
@@ -9,6 +8,7 @@ from app.dependencies import CurrentUserDep, PlanningServiceDep
|
||||
from app.models.planned_leave import (
|
||||
PlannedLeaveDayCreate,
|
||||
PlannedLeaveDayResponse,
|
||||
PlannedLeaveDayUpdate,
|
||||
)
|
||||
from app.utils.errors import NotFoundError, ValidationError
|
||||
|
||||
@@ -39,6 +39,16 @@ async def create_planned_day(
|
||||
raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc
|
||||
|
||||
|
||||
@router.get("", response_model=list[PlannedLeaveDayResponse])
|
||||
async def list_planned_days(
|
||||
service: PlanningServiceDep,
|
||||
_current_user: CurrentUserDep,
|
||||
child_id: UUID = Query(...),
|
||||
) -> list[PlannedLeaveDayResponse]:
|
||||
days = await service.list_by_child(child_id)
|
||||
return [_to_response(d) for d in days]
|
||||
|
||||
|
||||
@router.get("/{planned_leave_day_id}", response_model=PlannedLeaveDayResponse)
|
||||
async def get_planned_day(
|
||||
planned_leave_day_id: UUID,
|
||||
@@ -62,20 +72,22 @@ async def list_planned_days_by_workspace(
|
||||
return [_to_response(d) for d in days]
|
||||
|
||||
|
||||
@router.get("/range", response_model=list[PlannedLeaveDayResponse])
|
||||
async def list_planned_days_by_range(
|
||||
workspace_id: UUID = Query(...),
|
||||
child_id: UUID = Query(...),
|
||||
start_date: date = Query(...),
|
||||
end_date: date = Query(...),
|
||||
service: PlanningServiceDep = None,
|
||||
_current_user: CurrentUserDep = None,
|
||||
) -> list[PlannedLeaveDayResponse]:
|
||||
# Inject dependencies manually for query parameters
|
||||
|
||||
# Since we can't easily pass Query params with FastAPI dependencies,
|
||||
# we'll need to inject them differently
|
||||
pass
|
||||
@router.put("/{planned_leave_day_id}", response_model=PlannedLeaveDayResponse)
|
||||
async def update_planned_day(
|
||||
planned_leave_day_id: UUID,
|
||||
payload: PlannedLeaveDayUpdate,
|
||||
service: PlanningServiceDep,
|
||||
_current_user: CurrentUserDep,
|
||||
) -> PlannedLeaveDayResponse:
|
||||
try:
|
||||
day = await service.update(
|
||||
planned_leave_day_id,
|
||||
day_type=payload.day_type,
|
||||
is_dubbeldag=payload.is_dubbeldag,
|
||||
)
|
||||
return _to_response(day)
|
||||
except NotFoundError as exc:
|
||||
raise HTTPException(status.HTTP_404_NOT_FOUND, str(exc)) from exc
|
||||
|
||||
|
||||
@router.delete("/{planned_leave_day_id}", status_code=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
Reference in New Issue
Block a user