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:
parent
743129b11d
commit
fa07490b7b
6 changed files with 32 additions and 147 deletions
|
|
@ -41,15 +41,16 @@ class Permission(str, PyEnum):
|
|||
MANAGE_INVITES = "manage_invites"
|
||||
VIEW_OWN_INVITES = "view_own_invites"
|
||||
|
||||
# Booking permissions (regular users)
|
||||
BOOK_APPOINTMENT = "book_appointment"
|
||||
VIEW_OWN_APPOINTMENTS = "view_own_appointments"
|
||||
CANCEL_OWN_APPOINTMENT = "cancel_own_appointment"
|
||||
# Exchange permissions (regular users)
|
||||
CREATE_EXCHANGE = "create_exchange"
|
||||
VIEW_OWN_EXCHANGES = "view_own_exchanges"
|
||||
CANCEL_OWN_EXCHANGE = "cancel_own_exchange"
|
||||
|
||||
# Availability/Appointments permissions (admin)
|
||||
# Availability/Exchange permissions (admin)
|
||||
MANAGE_AVAILABILITY = "manage_availability"
|
||||
VIEW_ALL_APPOINTMENTS = "view_all_appointments"
|
||||
CANCEL_ANY_APPOINTMENT = "cancel_any_appointment"
|
||||
VIEW_ALL_EXCHANGES = "view_all_exchanges"
|
||||
CANCEL_ANY_EXCHANGE = "cancel_any_exchange"
|
||||
COMPLETE_EXCHANGE = "complete_exchange"
|
||||
|
||||
|
||||
class InviteStatus(str, PyEnum):
|
||||
|
|
@ -60,14 +61,6 @@ class InviteStatus(str, PyEnum):
|
|||
REVOKED = "revoked"
|
||||
|
||||
|
||||
class AppointmentStatus(str, PyEnum):
|
||||
"""Status of an appointment."""
|
||||
|
||||
BOOKED = "booked"
|
||||
CANCELLED_BY_USER = "cancelled_by_user"
|
||||
CANCELLED_BY_ADMIN = "cancelled_by_admin"
|
||||
|
||||
|
||||
class ExchangeStatus(str, PyEnum):
|
||||
"""Status of an exchange trade."""
|
||||
|
||||
|
|
@ -92,24 +85,25 @@ ROLE_REGULAR = "regular"
|
|||
# Role definitions with their permissions
|
||||
ROLE_DEFINITIONS: dict[str, RoleConfig] = {
|
||||
ROLE_ADMIN: {
|
||||
"description": "Administrator with audit/invite/appointment access",
|
||||
"description": "Administrator with audit/invite/exchange access",
|
||||
"permissions": [
|
||||
Permission.VIEW_AUDIT,
|
||||
Permission.FETCH_PRICE,
|
||||
Permission.MANAGE_INVITES,
|
||||
Permission.MANAGE_AVAILABILITY,
|
||||
Permission.VIEW_ALL_APPOINTMENTS,
|
||||
Permission.CANCEL_ANY_APPOINTMENT,
|
||||
Permission.VIEW_ALL_EXCHANGES,
|
||||
Permission.CANCEL_ANY_EXCHANGE,
|
||||
Permission.COMPLETE_EXCHANGE,
|
||||
],
|
||||
},
|
||||
ROLE_REGULAR: {
|
||||
"description": "Regular user with profile, invite, and booking access",
|
||||
"description": "Regular user with profile, invite, and exchange access",
|
||||
"permissions": [
|
||||
Permission.MANAGE_OWN_PROFILE,
|
||||
Permission.VIEW_OWN_INVITES,
|
||||
Permission.BOOK_APPOINTMENT,
|
||||
Permission.VIEW_OWN_APPOINTMENTS,
|
||||
Permission.CANCEL_OWN_APPOINTMENT,
|
||||
Permission.CREATE_EXCHANGE,
|
||||
Permission.VIEW_OWN_EXCHANGES,
|
||||
Permission.CANCEL_OWN_EXCHANGE,
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
@ -303,33 +297,6 @@ class Availability(Base):
|
|||
)
|
||||
|
||||
|
||||
class Appointment(Base):
|
||||
"""User appointment bookings."""
|
||||
|
||||
__tablename__ = "appointments"
|
||||
__table_args__ = (UniqueConstraint("slot_start", name="uq_appointment_slot_start"),)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
user_id: Mapped[int] = mapped_column(
|
||||
Integer, ForeignKey("users.id"), nullable=False, index=True
|
||||
)
|
||||
user: Mapped[User] = relationship("User", foreign_keys=[user_id], lazy="joined")
|
||||
slot_start: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), nullable=False, index=True
|
||||
)
|
||||
slot_end: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
|
||||
note: Mapped[str | None] = mapped_column(String(144), nullable=True)
|
||||
status: Mapped[AppointmentStatus] = mapped_column(
|
||||
Enum(AppointmentStatus), nullable=False, default=AppointmentStatus.BOOKED
|
||||
)
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), default=lambda: datetime.now(UTC)
|
||||
)
|
||||
cancelled_at: Mapped[datetime | None] = mapped_column(
|
||||
DateTime(timezone=True), nullable=True
|
||||
)
|
||||
|
||||
|
||||
class PriceHistory(Base):
|
||||
"""Price history records from external exchanges."""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue