Phase 0: Add booking permissions and constants
- Add AppointmentStatus enum (booked, cancelled_by_user, cancelled_by_admin) - Add booking permissions for regular users (book_appointment, view_own_appointments, cancel_own_appointment) - Add availability/appointments permissions for admin (manage_availability, view_all_appointments, cancel_any_appointment) - Add booking constants to shared/constants.json (slotDurationMinutes, maxAdvanceDays, minAdvanceDays, noteMaxLength) - Update validate_constants.py to validate new sections
This commit is contained in:
parent
c9b5cab0d6
commit
6c1a05d93d
3 changed files with 55 additions and 6 deletions
|
|
@ -2,7 +2,7 @@
|
|||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from models import ROLE_ADMIN, ROLE_REGULAR, InviteStatus
|
||||
from models import ROLE_ADMIN, ROLE_REGULAR, InviteStatus, AppointmentStatus
|
||||
|
||||
|
||||
def validate_shared_constants() -> None:
|
||||
|
|
@ -27,13 +27,28 @@ def validate_shared_constants() -> None:
|
|||
)
|
||||
|
||||
# Validate invite statuses
|
||||
expected_statuses = {s.name: s.value for s in InviteStatus}
|
||||
if constants.get("inviteStatuses") != expected_statuses:
|
||||
expected_invite_statuses = {s.name: s.value for s in InviteStatus}
|
||||
if constants.get("inviteStatuses") != expected_invite_statuses:
|
||||
raise ValueError(
|
||||
f"Invite status mismatch in shared/constants.json. "
|
||||
f"Expected: {expected_statuses}, Got: {constants.get('inviteStatuses')}"
|
||||
f"Expected: {expected_invite_statuses}, Got: {constants.get('inviteStatuses')}"
|
||||
)
|
||||
|
||||
# Validate appointment statuses
|
||||
expected_appointment_statuses = {s.name: s.value for s in AppointmentStatus}
|
||||
if constants.get("appointmentStatuses") != expected_appointment_statuses:
|
||||
raise ValueError(
|
||||
f"Appointment status mismatch in shared/constants.json. "
|
||||
f"Expected: {expected_appointment_statuses}, Got: {constants.get('appointmentStatuses')}"
|
||||
)
|
||||
|
||||
# Validate booking constants exist with required fields
|
||||
booking = constants.get("booking", {})
|
||||
required_booking_fields = ["slotDurationMinutes", "maxAdvanceDays", "minAdvanceDays", "noteMaxLength"]
|
||||
for field in required_booking_fields:
|
||||
if field not in booking:
|
||||
raise ValueError(f"Missing booking constant '{field}' in shared/constants.json")
|
||||
|
||||
# Validate validation rules exist (structure check only)
|
||||
validation = constants.get("validation", {})
|
||||
required_fields = ["telegram", "signal", "nostrNpub"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue