Fix: Update permission names, models and constants

Permission renames:
- BOOK_APPOINTMENT -> CREATE_EXCHANGE
- VIEW_OWN_APPOINTMENTS -> VIEW_OWN_EXCHANGES
- CANCEL_OWN_APPOINTMENT -> CANCEL_OWN_EXCHANGE
- VIEW_ALL_APPOINTMENTS -> VIEW_ALL_EXCHANGES
- CANCEL_ANY_APPOINTMENT -> CANCEL_ANY_EXCHANGE
- Add COMPLETE_EXCHANGE permission

Model changes:
- Delete AppointmentStatus enum
- Delete Appointment model

Schema changes:
- Delete BookingRequest (was for old booking)
- Delete AppointmentResponse, PaginatedAppointments
- Delete BookableSlot, AvailableSlotsResponse (unused)

Constants changes:
- Remove appointmentStatuses from shared/constants.json
- Merge booking constants into exchange section
- Update shared_constants.py and validate_constants.py
This commit is contained in:
counterweight 2025-12-22 20:28:21 +01:00
parent 743129b11d
commit fa07490b7b
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
6 changed files with 32 additions and 147 deletions

View file

@ -6,7 +6,6 @@ from typing import Generic, TypeVar
from pydantic import BaseModel, EmailStr, field_validator
from models import InviteStatus, Permission
from shared_constants import NOTE_MAX_LENGTH
class UserCredentials(BaseModel):
@ -173,51 +172,6 @@ class CopyAvailabilityRequest(BaseModel):
# =============================================================================
class BookableSlot(BaseModel):
"""A bookable 15-minute slot."""
start_time: datetime
end_time: datetime
class AvailableSlotsResponse(BaseModel):
"""Response for available slots on a given date."""
date: date
slots: list[BookableSlot]
class BookingRequest(BaseModel):
"""Request to book an appointment."""
slot_start: datetime
note: str | None = None
@field_validator("note")
@classmethod
def validate_note_length(cls, v: str | None) -> str | None:
if v is not None and len(v) > NOTE_MAX_LENGTH:
raise ValueError(f"Note must be at most {NOTE_MAX_LENGTH} characters")
return v
class AppointmentResponse(BaseModel):
"""Response model for an appointment."""
id: int
user_id: int
user_email: str
slot_start: datetime
slot_end: datetime
note: str | None
status: str
created_at: datetime
cancelled_at: datetime | None
PaginatedAppointments = PaginatedResponse[AppointmentResponse]
# =============================================================================
# Price History Schemas
# =============================================================================