Booking Internal Modules
The booking package is built from adapters, selectors, and abstract model mixins. This section indexes those implementation modules directly.
Selectors
codex_django.booking.selectors
codex_django.booking.selectors
Pure-function selectors for booking operations.
These are the high-level entry points for views and CLI-generated features. The adapter is passed as an argument (dependency injection).
Rules enforced
R1 — Cache invalidation via transaction.on_commit() only.
R2 — lock_masters() uses select_for_update(of=('self',)).
Classes
BookingPersistenceHook
Bases: Protocol
Protocol for project-specific multi-service persistence.
Source code in src/codex_django/booking/selectors.py
33 34 35 36 37 38 39 40 41 42 43 44 | |
Functions
persist_chain(solution, service_ids, client, extra_fields=None)
Persist a multi-service chain and return appointment-like objects.
Source code in src/codex_django/booking/selectors.py
36 37 38 39 40 41 42 43 44 | |
Functions
get_available_slots(adapter, service_ids, target_date, *, locked_master_id=None, master_selections=None, mode=BookingMode.SINGLE_DAY, overlap_allowed=False, parallel_groups=None, max_solutions=50, max_unique_starts=None, cache_ttl=300)
Compute available booking slots for a given date.
Builds the engine request, fetches master availability, and runs
ChainFinder.find().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
DjangoAvailabilityAdapter
|
Availability adapter that bridges Django models to the engine. |
required |
service_ids
|
list[int]
|
Ordered list of requested service identifiers. |
required |
target_date
|
date
|
Date for which slots should be computed. |
required |
locked_master_id
|
int | None
|
Optional master id that constrains the search. |
None
|
master_selections
|
MasterSelections
|
Optional per-service master selection mapping. |
None
|
mode
|
BookingMode
|
Booking engine search mode. |
SINGLE_DAY
|
overlap_allowed
|
bool
|
Whether services may overlap in time. |
False
|
parallel_groups
|
dict[int, str] | None
|
Optional mapping of service id to parallel group id. |
None
|
max_solutions
|
int
|
Maximum number of engine solutions to compute. |
50
|
max_unique_starts
|
int | None
|
Optional cap for unique start times. |
None
|
cache_ttl
|
int
|
Cache lifetime in seconds for busy-slot reads. |
300
|
Returns:
| Type | Description |
|---|---|
EngineResult
|
Engine result produced by |
Source code in src/codex_django/booking/selectors.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
get_calendar_data(year, month, today=None, selected_date=None, holidays_subdiv='ST')
Generate a calendar month matrix for UI rendering.
Wraps CalendarEngine.get_month_matrix() from codex-services.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Target calendar year. |
required |
month
|
int
|
Target calendar month. |
required |
today
|
date | None
|
Optional date used to highlight the current day. |
None
|
selected_date
|
date | None
|
Optional date selected in the UI. |
None
|
holidays_subdiv
|
str
|
Region code passed to the calendar engine. |
'ST'
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
Calendar matrix data ready for template rendering. |
Source code in src/codex_django/booking/selectors.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
get_nearest_slots(adapter, service_ids, search_from, *, locked_master_id=None, master_selections=None, mode=BookingMode.SINGLE_DAY, overlap_allowed=False, parallel_groups=None, search_days=60, max_solutions_per_day=1)
Search for the nearest available date with open slots (waitlist).
Uses ChainFinder.find_nearest() which scans forward day by day.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
DjangoAvailabilityAdapter
|
Availability adapter that bridges Django models to the engine. |
required |
service_ids
|
list[int]
|
Ordered list of requested service identifiers. |
required |
search_from
|
date
|
First date included in the forward search. |
required |
locked_master_id
|
int | None
|
Optional master id that constrains the search. |
None
|
master_selections
|
MasterSelections
|
Optional per-service master selection mapping. |
None
|
mode
|
BookingMode
|
Booking engine search mode. |
SINGLE_DAY
|
overlap_allowed
|
bool
|
Whether services may overlap in time. |
False
|
parallel_groups
|
dict[int, str] | None
|
Optional mapping of service id to parallel group id. |
None
|
search_days
|
int
|
Number of forward days to inspect. |
60
|
max_solutions_per_day
|
int
|
Maximum number of solutions evaluated per day. |
1
|
Returns:
| Type | Description |
|---|---|
EngineResult
|
Engine result produced by |
Source code in src/codex_django/booking/selectors.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
create_booking(adapter, cache_adapter, appointment_model, *, service_ids, target_date, selected_time, master_id, client, extra_fields=None, master_selections=None, mode=BookingMode.SINGLE_DAY, overlap_allowed=False, parallel_groups=None, persistence_hook=None)
Create a booking with concurrency protection.
Solo mode:
1. Locks a single master row
2. Re-checks slot availability under lock
3. Creates one appointment
4. Invalidates cache after commit (R1: transaction.on_commit())
Multi-service mode:
1. Requires a persistence_hook
2. Locks all candidate masters for the chain
3. Re-checks chain availability under lock
4. Delegates persistence to persistence_hook.persist_chain()
5. Invalidates cache for chain masters after commit
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
DjangoAvailabilityAdapter
|
Availability adapter used for locking and revalidation. |
required |
cache_adapter
|
BookingCacheAdapter
|
Cache adapter used for post-commit invalidation. |
required |
appointment_model
|
type[Any]
|
Concrete Django model class for appointment rows. |
required |
service_ids
|
list[int]
|
Ordered list of requested service identifiers. |
required |
target_date
|
date
|
Booking date selected by the client. |
required |
selected_time
|
str
|
Selected start time in |
required |
master_id
|
int
|
Master chosen for single-service mode. |
required |
client
|
Any
|
Client object attached to the booking. |
required |
extra_fields
|
dict[str, Any] | None
|
Optional extra model fields passed to persistence. |
None
|
master_selections
|
MasterSelections
|
Optional per-service master selection mapping. |
None
|
mode
|
BookingMode
|
Booking engine search mode. |
SINGLE_DAY
|
overlap_allowed
|
bool
|
Whether services may overlap in time. |
False
|
parallel_groups
|
dict[int, str] | None
|
Optional mapping of service id to parallel group id. |
None
|
persistence_hook
|
BookingPersistenceHook | None
|
Required persistence hook for multi-service mode. |
None
|
Returns:
| Type | Description |
|---|---|
Any | list[Any]
|
A single appointment instance in solo mode, or a list of created |
Any | list[Any]
|
appointment-like objects in multi-service mode. |
Raises:
| Type | Description |
|---|---|
SlotAlreadyBookedError
|
If the selected slot is no longer available under lock. |
NotImplementedError
|
If multi-service mode is requested without a persistence hook. |
Source code in src/codex_django/booking/selectors.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
Availability adapter
codex_django.booking.adapters.availability
codex_django.booking.adapters.availability
Universal bridge between Django ORM and the codex-services booking engine.
All models are injected at construction time — no hardcoded imports.
Rules enforced
R1 — Cache invalidation via transaction.on_commit() only (see selectors).
R2 — select_for_update(of=('self',)) in lock_masters().
R3 — No clean/save overrides here; pure adapter logic.
Classes
DjangoAvailabilityAdapter
Universal bridge between Django ORM and the booking engine.
Implements the three provider interfaces from codex-services so it
can be used directly with ChainFinder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
master_model
|
type[Any]
|
Django model class for masters/resources. |
required |
appointment_model
|
type[Any]
|
Django model class for appointments. |
required |
service_model
|
type[Any]
|
Django model class for services. |
required |
working_day_model
|
type[Any]
|
Django model class for per-weekday schedule. |
required |
day_off_model
|
type[Any]
|
Django model class for days off. |
required |
booking_settings_model
|
type[Any]
|
Django model class for booking settings. |
required |
site_settings_model
|
type[Any]
|
Django model class for site-level settings. |
required |
step_minutes
|
int
|
Time grid step for the engine. |
30
|
appointment_status_filter
|
list[str] | None
|
Which statuses count as "busy". |
None
|
cache_adapter
|
BookingCacheAdapter | None
|
Optional cache adapter; defaults to BookingCacheAdapter. |
None
|
Source code in src/codex_django/booking/adapters/availability.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | |
Functions
build_engine_request(service_ids, target_date, locked_master_id=None, master_selections=None, mode=BookingMode.SINGLE_DAY, overlap_allowed=False, parallel_groups=None)
Build a BookingEngineRequest from DB service/master data.
Source code in src/codex_django/booking/adapters/availability.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
build_masters_availability(master_ids, target_date, cache_ttl=0, exclude_appointment_ids=None)
Build MasterAvailability dicts from ORM data.
Caches busy intervals (not free slots) per master+date.
Source code in src/codex_django/booking/adapters/availability.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
get_working_hours(master, target_date)
Return UTC working hours for a master on a specific date.
Reads from working_day_model first; falls back to
master-level defaults, then site-level defaults.
Source code in src/codex_django/booking/adapters/availability.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | |
get_break_interval(master, target_date)
Return UTC break interval for a master on a date.
Source code in src/codex_django/booking/adapters/availability.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
lock_masters(master_ids)
Acquire row-level locks on master records.
Must be called inside transaction.atomic().
IDs are sorted to prevent deadlocks.
Source code in src/codex_django/booking/adapters/availability.py
273 274 275 276 277 278 279 280 281 282 | |
result_to_slots_map(result)
Convert an engine result to a simple {HH:MM: True} map.
Source code in src/codex_django/booking/adapters/availability.py
318 319 320 321 | |
Cache adapter
codex_django.booking.adapters.cache
codex_django.booking.adapters.cache
Thin adapter over BookingCacheManager for busy slot caching.
Follows the same pattern as notifications.adapters.cache_adapter.DjangoCacheAdapter.
Classes
BookingCacheAdapter
Delegates to BookingCacheManager.
Used by DjangoAvailabilityAdapter to cache/invalidate busy intervals.
Source code in src/codex_django/booking/adapters/cache.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
Functions
get_busy(master_id, date_str)
Return cached busy intervals for a master on a specific date.
Source code in src/codex_django/booking/adapters/cache.py
20 21 22 23 | |
set_busy(master_id, date_str, intervals, timeout=300)
Store busy intervals for a master/date cache bucket.
Source code in src/codex_django/booking/adapters/cache.py
25 26 27 28 29 30 31 32 33 34 | |
invalidate_master_date(master_id, date_str)
Invalidate the busy-interval cache for one master/date pair.
Source code in src/codex_django/booking/adapters/cache.py
36 37 38 39 | |
Functions
Service mixins
codex_django.booking.mixins.service
codex_django.booking.mixins.service
Composable mixins for the bookable service model.
Usage::
from codex_django.booking.mixins import AbstractBookableService
class Service(AbstractBookableService):
name = models.CharField(max_length=255)
price = models.DecimalField(...)
category = models.ForeignKey(...)
class Meta:
verbose_name = _("Service")
Classes
ServiceDurationMixin
Bases: Model
Service duration in minutes.
Admin fieldsets example::
(_("Duration"), {
"fields": ("duration",),
}),
Source code in src/codex_django/booking/mixins/service.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
ServiceGapMixin
Bases: Model
Minimum gap after this service before the next one starts.
Admin fieldsets example::
(_("Gap"), {
"fields": ("min_gap_after_minutes",),
"classes": ("collapse",),
}),
Source code in src/codex_django/booking/mixins/service.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
ServiceParallelMixin
Bases: Model
Controls whether this service can run in parallel with others.
Admin fieldsets example::
(_("Parallel Booking"), {
"fields": ("parallel_ok", "parallel_group"),
"classes": ("collapse",),
}),
Source code in src/codex_django/booking/mixins/service.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
AbstractBookableService
Bases: ServiceDurationMixin, ServiceGapMixin, ServiceParallelMixin, Model
Convenience base that assembles all service mixins.
Usage::
class Service(AbstractBookableService):
name = models.CharField(max_length=255)
price = models.DecimalField(max_digits=10, decimal_places=2)
class Meta:
verbose_name = _("Service")
Source code in src/codex_django/booking/mixins/service.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
Master mixins
codex_django.booking.mixins.master
codex_django.booking.mixins.master
Composable mixins for the master/resource/specialist model.
Usage::
from codex_django.booking.mixins import AbstractBookableMaster
class Master(AbstractBookableMaster):
name = models.CharField(max_length=255)
# ... project-specific fields
class Meta:
verbose_name = _("Master")
Or pick individual mixins::
class Master(MasterScheduleMixin, MasterBufferMixin, models.Model):
...
Classes
MasterScheduleMixin
Bases: Model
Default working hours and breaks.
These serve as fallback values. Per-day overrides live in the
AbstractWorkingDay relational model (see schedule.py).
Admin fieldsets example::
(_("Working Hours"), {
"fields": (
"work_start", "work_end",
"break_start", "break_end",
),
}),
Source code in src/codex_django/booking/mixins/master.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
MasterBufferMixin
Bases: Model
Buffer time and advance booking limits.
Admin fieldsets example::
(_("Booking Constraints"), {
"fields": (
"buffer_between_minutes",
"min_advance_minutes",
"max_advance_days",
),
"classes": ("collapse",),
}),
Source code in src/codex_django/booking/mixins/master.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
MasterCapacityMixin
Bases: Model
Parallel client capacity.
Admin fieldsets example::
(_("Capacity"), {
"fields": ("max_clients_parallel",),
}),
Source code in src/codex_django/booking/mixins/master.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
MasterTimezoneMixin
Bases: Model
Individual timezone for the master.
Falls back to site-level timezone when empty.
Admin fieldsets example::
(_("Timezone"), {
"fields": ("timezone",),
"classes": ("collapse",),
}),
Source code in src/codex_django/booking/mixins/master.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
AbstractBookableMaster
Bases: MasterScheduleMixin, MasterBufferMixin, MasterCapacityMixin, MasterTimezoneMixin, Model
Convenience base that assembles all master mixins.
Usage::
class Master(AbstractBookableMaster):
name = models.CharField(max_length=255)
status = models.CharField(...)
categories = models.ManyToManyField(...)
class Meta:
verbose_name = _("Master")
Source code in src/codex_django/booking/mixins/master.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
Appointment mixins
codex_django.booking.mixins.appointment
codex_django.booking.mixins.appointment
Composable mixins for the appointment/booking record model.
Usage::
from codex_django.booking.mixins import AbstractBookableAppointment
class Appointment(AbstractBookableAppointment):
master = models.ForeignKey("masters.Master", ...)
service = models.ForeignKey("services.Service", ...)
client = models.ForeignKey(settings.AUTH_USER_MODEL, ...)
class Meta:
verbose_name = _("Appointment")
FK fields are NOT included — the user defines them pointing at their own Master/Service/Client models.
Classes
AppointmentStatusMixin
Bases: Model
Appointment lifecycle status.
Status constants are class-level attributes so that the adapter and selectors can reference them without hardcoding strings::
Appointment.STATUS_PENDING
Appointment.STATUS_CONFIRMED
Admin fieldsets example::
(_("Status"), {
"fields": ("status",),
}),
Source code in src/codex_django/booking/mixins/appointment.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
AppointmentCoreMixin
Bases: Model
Core booking data: when and how long.
Admin fieldsets example::
(_("Booking Details"), {
"fields": ("datetime_start", "duration_minutes"),
}),
Source code in src/codex_django/booking/mixins/appointment.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
AbstractBookableAppointment
Bases: AppointmentStatusMixin, AppointmentCoreMixin, Model
Convenience base that assembles all appointment mixins.
Usage::
class Appointment(AbstractBookableAppointment):
master = models.ForeignKey("masters.Master", on_delete=models.CASCADE)
service = models.ForeignKey("services.Service", on_delete=models.CASCADE)
client = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
class Meta:
verbose_name = _("Appointment")
ordering = ["-datetime_start"]
Source code in src/codex_django/booking/mixins/appointment.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
Schedule mixins
codex_django.booking.mixins.schedule
codex_django.booking.mixins.schedule
Relational models for master working schedule and days off.
AbstractWorkingDay replaces JSONField work_days — gives proper SQL
filtering, per-day hours, and index support.
Usage::
from codex_django.booking.mixins import AbstractWorkingDay, MasterDayOffMixin
class MasterWorkingDay(AbstractWorkingDay):
master = models.ForeignKey(
"masters.Master",
on_delete=models.CASCADE,
related_name="working_days",
)
class Meta:
verbose_name = _("Working Day")
unique_together = [("master", "weekday")]
class MasterDayOff(MasterDayOffMixin):
master = models.ForeignKey(
"masters.Master",
on_delete=models.CASCADE,
related_name="days_off",
)
class Meta:
verbose_name = _("Day Off")
unique_together = [("master", "date")]
Classes
AbstractWorkingDay
Bases: Model
Per-weekday schedule for a master.
FK to the master model is NOT included — the user adds it pointing at their own model.
Admin fieldsets example::
(_("Schedule"), {
"fields": ("weekday", "start_time", "end_time", "break_start", "break_end"),
}),
Source code in src/codex_django/booking/mixins/schedule.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
MasterDayOffMixin
Bases: Model
A single day-off record for a master.
FK to the master model is NOT included — the user adds it.
Admin fieldsets example::
(_("Day Off"), {
"fields": ("date", "reason"),
}),
Source code in src/codex_django/booking/mixins/schedule.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
Settings mixins
codex_django.booking.mixins.settings
codex_django.booking.mixins.settings
Booking system configuration model mixins.
Usage::
from codex_django.booking.mixins import AbstractBookingSettings
class BookingSettings(AbstractBookingSettings):
class Meta:
verbose_name = _("Booking Settings")
# In your Django settings:
# CODEX_BOOKING_SETTINGS_MODEL = 'system.BookingSettings'
Classes
BookingSettingsMixin
Bases: Model
Core booking configuration fields.
Admin fieldsets example::
(_("Booking Defaults"), {
"fields": (
"step_minutes",
"default_buffer_between_minutes",
"min_advance_minutes",
"max_advance_days",
),
}),
(_("Default Working Hours — Weekdays"), {
"fields": ("work_start_weekdays", "work_end_weekdays"),
}),
(_("Default Working Hours — Saturday"), {
"fields": ("work_start_saturday", "work_end_saturday"),
"classes": ("collapse",),
}),
Source code in src/codex_django/booking/mixins/settings.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
Functions
to_dict()
Serialize concrete fields for Redis storage.
Source code in src/codex_django/booking/mixins/settings.py
78 79 80 81 82 83 84 85 86 87 | |
BookingSettingsSyncMixin
Bases: LifecycleModelMixin, Model
Sync booking settings to Redis on save.
Follows rule R1: Redis errors are swallowed with logging so that a Redis outage never prevents saving settings in the database.
Source code in src/codex_django/booking/mixins/settings.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
Functions
sync_booking_settings_to_redis()
Persist the latest booking settings payload to Redis after save.
Source code in src/codex_django/booking/mixins/settings.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
AbstractBookingSettings
Bases: BookingSettingsMixin, BookingSettingsSyncMixin, Model
Convenience base that assembles settings fields + Redis sync.
Usage::
class BookingSettings(AbstractBookingSettings):
class Meta:
verbose_name = _("Booking Settings")
Source code in src/codex_django/booking/mixins/settings.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |