Expune fluxul de rezervare anonimă printr-un link public partajabil
(/book/<slug>), cu calendar public, cod QR și proprietate demo publică.
Backend:
- slug + list_on_landing pe Property; utilitar slugify (diacritice RO,
cuvinte rezervate, ban all-digit) + migrare idempotentă raw-DDL rulată
din entrypoint; SQLite WAL + busy_timeout
- GET /public/properties/{slug_or_id}(+/spaces): rezolvare slug/ID, 404 uniform
- GET /public/spaces/{id}/busy: doar {start_time,end_time} (fără PII),
pending+approved, tz-aware/interval>60z → 422, orfan/privat → 404
- availability: scrub user_name/title (fix scurgere PII)
- POST /public/bookings: overlap pending+approved, cap 5/email/spațiu/zi,
rate-limit per-IP, suprimare notificări+email pe demo, email confirmare guest
- PATCH slug (409 duplicat / 422 format / 403 non-manager); guest_email EmailStr
- email guest la aprobare/respingere cu cod #RB-<id>
- teste noi: test_public.py + test_migrate_slug.py (33 teste)
Frontend:
- rută /book/:slug; PublicBooking rescris cu calendar grid manual
(PublicCalendar + GuestBookingForm), 30min, 08-20, mobil day-view, RO
- card „Link public" în PropertyDetail: copy, edit slug, QR pe URL-ul cu ID
- secțiune proprietăți publice + CTA pe Landing; buton copy în Properties
Gate aprobat (U1-U3, G1 grid manual, G2 list_on_landing); G3-G5 în TODOS.md.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
89 lines
2.1 KiB
Python
89 lines
2.1 KiB
Python
"""Property schemas."""
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class PropertyCreate(BaseModel):
|
|
name: str = Field(..., min_length=1)
|
|
description: str | None = None
|
|
address: str | None = None
|
|
is_public: bool = True
|
|
list_on_landing: bool = False
|
|
|
|
|
|
class PropertyUpdate(BaseModel):
|
|
name: str | None = None
|
|
description: str | None = None
|
|
address: str | None = None
|
|
is_public: bool | None = None
|
|
slug: str | None = None
|
|
list_on_landing: bool | None = None
|
|
|
|
|
|
class PropertyManagerInfo(BaseModel):
|
|
user_id: int
|
|
full_name: str
|
|
email: str
|
|
|
|
|
|
class PropertyResponse(BaseModel):
|
|
id: int
|
|
name: str
|
|
description: str | None = None
|
|
address: str | None = None
|
|
is_public: bool
|
|
is_active: bool
|
|
created_at: datetime
|
|
space_count: int = 0
|
|
managers: list[PropertyManagerInfo] = []
|
|
slug: str | None = None
|
|
list_on_landing: bool = False
|
|
require_approval: bool | None = None
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class PropertyWithSpaces(PropertyResponse):
|
|
spaces: list = []
|
|
|
|
|
|
class PropertyAccessCreate(BaseModel):
|
|
user_id: int | None = None
|
|
organization_id: int | None = None
|
|
|
|
|
|
class PropertyAccessResponse(BaseModel):
|
|
id: int
|
|
property_id: int
|
|
user_id: int | None = None
|
|
organization_id: int | None = None
|
|
granted_by: int | None = None
|
|
user_name: str | None = None
|
|
user_email: str | None = None
|
|
organization_name: str | None = None
|
|
created_at: datetime
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class PropertySettingsUpdate(BaseModel):
|
|
working_hours_start: int | None = None
|
|
working_hours_end: int | None = None
|
|
min_duration_minutes: int | None = None
|
|
max_duration_minutes: int | None = None
|
|
max_bookings_per_day_per_user: int | None = None
|
|
require_approval: bool = True
|
|
min_hours_before_cancel: int | None = None
|
|
|
|
|
|
class PropertySettingsResponse(PropertySettingsUpdate):
|
|
id: int
|
|
property_id: int
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class PropertyStatusUpdate(BaseModel):
|
|
is_active: bool
|