Files
gartenmanager/backend/app/crud/planting.py
Faultier314 834a3bf4d5 feat: Phase 1 complete – full working application
Backend (FastAPI):
- REST API: auth, plants, beds, plantings
- CRUD layer with CRUDBase
- Pydantic v2 schemas for all entities
- Alembic migration: complete schema + all enums
- Seed data: 28 global plants + 15 compatibilities

Frontend (Vue 3 + PrimeVue):
- Axios client with JWT interceptor + auto-refresh
- Pinia stores: auth, beds, plants
- Views: Login, Beds, BedDetail, PlantLibrary
- Components: AppLayout, BedForm, PlantingForm, PlantForm

Docker:
- docker-compose.yml (production)
- docker-compose.dev.yml (development with hot-reload)
- Nginx config with SPA fallback + API proxy
- Multi-stage frontend Dockerfile
- .env.example, .gitignore

Version: 1.0.0-alpha
2026-04-06 07:45:00 +02:00

40 lines
1.3 KiB
Python

from uuid import UUID
from sqlalchemy import select
from sqlalchemy.orm import selectinload
from sqlalchemy.ext.asyncio import AsyncSession
from app.crud.base import CRUDBase
from app.models.planting import BedPlanting
from app.models.plant import Plant
from app.schemas.planting import PlantingCreate, PlantingUpdate
class CRUDPlanting(CRUDBase[BedPlanting, PlantingCreate, PlantingUpdate]):
async def get(self, db: AsyncSession, *, id: UUID) -> BedPlanting | None:
result = await db.execute(
select(BedPlanting)
.options(selectinload(BedPlanting.plant).selectinload(Plant.family))
.where(BedPlanting.id == id)
)
return result.scalar_one_or_none()
async def get_multi_for_bed(
self, db: AsyncSession, *, bed_id: UUID
) -> list[BedPlanting]:
result = await db.execute(
select(BedPlanting)
.options(selectinload(BedPlanting.plant).selectinload(Plant.family))
.where(BedPlanting.bed_id == bed_id)
.order_by(BedPlanting.planted_date.desc().nullslast())
)
return list(result.scalars().all())
async def create_for_bed(
self, db: AsyncSession, *, obj_in: PlantingCreate, bed_id: UUID
) -> BedPlanting:
return await self.create(db, obj_in=obj_in, bed_id=bed_id)
crud_planting = CRUDPlanting(BedPlanting)