Core Internal Modules
These modules back the public core helpers and expose the implementation-level docstrings for context processors, mixins, selectors, and Redis integration.
Context processors
codex_django.core.context_processors
Context processors for cross-project core concerns.
Currently this module provides template access to resolved static-page SEO metadata so frontend templates can render canonical titles and descriptions without repeating selector logic in views.
Functions
seo_settings(request)
Expose SEO metadata for the current resolved page in templates.
The returned mapping is injected into the template context as seo.
The processor expects CODEX_STATIC_PAGE_SEO_MODEL to point to a
model that can be consumed by
:func:codex_django.core.seo.selectors.get_static_page_seo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
HttpRequest
|
Incoming Django request used to resolve the current URL name. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A template context mapping with the |
dict[str, Any]
|
dictionary payload when the current route cannot be resolved or when |
dict[str, Any]
|
no SEO data is available for the page. |
Source code in src/codex_django/core/context_processors.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
Model mixins
codex_django.core.mixins.models
Reusable abstract Django model mixins shared across codex-django packages.
Examples:
Combine several mixins in a project model::
from django.db import models
from codex_django.core.mixins.models import TimestampMixin, ActiveMixin, SeoMixin
class Article(TimestampMixin, ActiveMixin, SeoMixin, models.Model):
title = models.CharField(max_length=200)
Classes
TimestampMixin
Bases: Model
Add creation and update timestamps to a model.
Notes
created_at is written once on insert, while updated_at is
refreshed on every save.
Admin
fieldsets: (_("Timestamps"), {"fields": ("created_at", "updated_at"), "classes": ("collapse",)}) readonly_fields: ("created_at", "updated_at")
Source code in src/codex_django/core/mixins/models.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
ActiveMixin
Bases: Model
Add an is_active flag for publication and visibility control.
Notes
Use this mixin when objects should remain queryable in the database but be hidden from public listings, navigation, or API responses.
Admin
fieldsets: (_("Status"), {"fields": ("is_active",)}) list_filter: ("is_active",)
Source code in src/codex_django/core/mixins/models.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
SeoMixin
Bases: Model
Add basic per-object SEO fields for title, description, and OG image.
Notes
This mixin is intended for content models that need per-instance metadata overrides in templates, cards, or sitemap-adjacent views.
Admin
fieldsets: (_("SEO Settings"), {"fields": ("seo_title", "seo_description", "seo_image"), "classes": ("collapse",)})
Source code in src/codex_django/core/mixins/models.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
OrderableMixin
Bases: Model
Add a generic order field for custom manual sorting.
Notes
The mixin sets Meta.ordering = ["order"] on the abstract base.
Admin
fieldsets:
(_("Ordering"), {"fields": ("order",)})
list_display:
include order when manual ordering should be visible in admin.
Source code in src/codex_django/core/mixins/models.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
SoftDeleteMixin
Bases: Model
Add an is_deleted flag for soft-deletion workflows.
Notes
The model instance remains in the database. Call soft_delete()
when the project wants reversible deletion semantics.
Admin
fieldsets: (_("Archive / Deletion"), {"fields": ("is_deleted",), "classes": ("collapse",)}) list_filter: ("is_deleted",)
Source code in src/codex_django/core/mixins/models.py
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 | |
Functions
soft_delete()
Mark the object as deleted without removing the database row.
Notes
The method updates is_deleted and immediately saves the model
instance using the default manager behavior.
Source code in src/codex_django/core/mixins/models.py
120 121 122 123 124 125 126 127 128 | |
UUIDMixin
Bases: Model
Replace the default integer primary key with a UUID4 identifier.
Notes
This mixin is useful for public-facing URLs or distributed systems where sequential integer identifiers should not be exposed.
Admin
fieldsets: (_("Identifiers"), {"fields": ("id",), "classes": ("collapse",)}) readonly_fields: ("id",)
Source code in src/codex_django/core/mixins/models.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
SlugMixin
Bases: Model
Add a unique slug field suitable for URL routing.
Notes
The field is intentionally declared with blank=True so projects
can populate it through admin prepopulation, model hooks, or custom
save logic.
Admin
fieldsets:
(_("URL"), {"fields": ("slug",)})
prepopulated_fields:
{"slug": ("title",)} # Replace title with the concrete source field.
Source code in src/codex_django/core/mixins/models.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
Sitemaps
codex_django.core.sitemaps
Sitemap primitives with codex-django defaults.
The base sitemap centralizes canonical-domain handling, multilingual URL generation, and namespace-aware reverse lookups so project sitemaps can stay small and focused.
Classes
BaseSitemap
Bases: Sitemap
Base sitemap with Codex defaults for multilingual canonical URLs.
The implementation enables Django's i18n sitemap mode, forces canonical
HTTPS URLs, and centralizes domain resolution through
settings.CANONICAL_DOMAIN.
Source code in src/codex_django/core/sitemaps.py
16 17 18 19 20 21 22 23 24 25 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 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 | |
Functions
location(item)
Resolve sitemap items to absolute path components.
String items are treated as URL pattern names and are first reversed
directly, then retried against namespaces listed in
settings.SITEMAP_LOOKUP_NAMESPACES. Non-string items are expected
to implement get_absolute_url().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
Any
|
Sitemap item emitted by Django. In i18n mode Django may pass
either the raw item or an |
required |
Returns:
| Type | Description |
|---|---|
str
|
The resolved path component for the sitemap entry. |
Raises:
| Type | Description |
|---|---|
NoReverseMatch
|
If a string item cannot be reversed directly or through the configured namespace fallbacks. |
Source code in src/codex_django/core/sitemaps.py
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 | |
SEO selectors
codex_django.core.seo.selectors
Selectors for static-page SEO metadata.
Examples:
Load cached SEO payload for a resolved page name::
seo = get_static_page_seo("home")
Functions
get_static_page_seo(page_key)
Load SEO metadata for a static page, using Redis as a read-through cache.
The helper first checks the centralized SEO Redis manager. On a cache
miss, it resolves the model declared by
settings.CODEX_STATIC_PAGE_SEO_MODEL, fetches the matching record by
page_key, flattens it to a string-only mapping, and stores the result
back in Redis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_key
|
str
|
Logical key that identifies the static page. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Cached or freshly loaded SEO data as a mapping-like object, or |
Any
|
|
Any
|
or loading fails. |
Source code in src/codex_django/core/seo/selectors.py
21 22 23 24 25 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 | |
i18n discovery
codex_django.core.i18n.discovery
Helpers for discovering Django locale directories.
Examples:
Resolve locale paths for a generated project root::
from pathlib import Path
from codex_django.core.i18n import discover_locale_paths
LOCALE_PATHS = discover_locale_paths(Path(BASE_DIR))
Functions
discover_locale_paths(base_dir, include_features=True)
Discover locale directories that should be added to LOCALE_PATHS.
The helper supports both a centralized locale/<domain>/<lang>
structure and per-app locale/ directories. Feature apps under
base_dir / "features" can be included or skipped explicitly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_dir
|
Path
|
Project root that contains apps, optional |
required |
include_features
|
bool
|
Whether locale directories inside the |
True
|
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of locale directory paths suitable for Django's |
list[str]
|
|
list[str]
|
are de-duplicated across supported layouts. |
Source code in src/codex_django/core/i18n/discovery.py
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
Translation command
codex_django.core.management.commands.codex_makemessages
Domain-aware wrapper around Django's makemessages command.
The command scans a Codex project for template-bearing domains, creates
centralized locale/<domain>/ directories, and runs Django's
makemessages command separately for each domain plus a shared
common bucket.
Examples:
Preview what would be generated without writing files::
python manage.py codex_makemessages --dry-run
Classes
Command
Bases: BaseCommand
Generate modular translation catalogs for Codex project layouts.
The command understands three common template layouts:
- root-level
templates/<domain>/ - app-local
<app>/templates/ - feature-local
features/<feature>/templates/
Source code in src/codex_django/core/management/commands/codex_makemessages.py
24 25 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 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 | |
Functions
add_arguments(parser)
Register command-line arguments for the management command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parser
|
ArgumentParser
|
Django/argparse parser instance for this command. |
required |
Source code in src/codex_django/core/management/commands/codex_makemessages.py
39 40 41 42 43 44 45 46 47 48 49 | |
handle(*args, **options)
Discover domains and run makemessages for each one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments forwarded by Django's command runner. |
()
|
**options
|
Any
|
Parsed command-line options. |
{}
|
Source code in src/codex_django/core/management/commands/codex_makemessages.py
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 | |
Template tags
codex_django.core.templatetags.codex_i18n
Template tags for multilingual navigation helpers.
The tags in this module are intentionally small wrappers around Django's i18n utilities so templates can stay declarative.
Functions
translate_url(context, lang_code)
Translate the current request path into another active language.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, Any]
|
Template context expected to contain the current |
required |
lang_code
|
str
|
Target Django language code. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The translated URL path for the current request, or an empty string |
str
|
when the request is unavailable. |
Source code in src/codex_django/core/templatetags/codex_i18n.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
Redis base manager
codex_django.core.redis.managers.base
Base Redis manager utilities adapted to Django settings.
This module is the bridge between codex-platform Redis helpers and the Django settings conventions used by codex-django projects.
Classes
BaseDjangoRedisManager
Bases: BaseRedisManager
Base Redis manager adapted for Django settings and project namespacing.
Source code in src/codex_django/core/redis/managers/base.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 40 41 | |
Functions
make_key(key)
Build a namespaced Redis key for the current Django project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Logical key suffix for the concrete cache entry. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A colon-delimited Redis key in the |
str
|
|
str
|
omitted. |
Source code in src/codex_django/core/redis/managers/base.py
25 26 27 28 29 30 31 32 33 34 35 36 37 | |
Redis settings manager
codex_django.core.redis.managers.settings
Redis-backed site settings storage helpers.
The settings manager caches the concrete project settings model in a single Redis hash and exposes a lightweight proxy for template access.
Classes
SettingsProxy
Expose dictionary-backed settings through attribute-style access in templates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Flat settings payload loaded from Redis or the database. |
required |
Source code in src/codex_django/core/redis/managers/settings.py
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 40 41 42 43 44 45 | |
Functions
__getattr__(name)
Return a setting value using attribute access semantics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Setting key to resolve. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The stored value, or an empty string when the key is missing. |
Source code in src/codex_django/core/redis/managers/settings.py
25 26 27 28 29 30 31 32 33 34 | |
__getitem__(name)
Return a setting value using dictionary-style indexing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Setting key to resolve. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The stored value, or an empty string when the key is missing. |
Source code in src/codex_django/core/redis/managers/settings.py
36 37 38 39 40 41 42 43 44 45 | |
DjangoSiteSettingsManager
Bases: BaseDjangoRedisManager
Load and persist site settings in Redis with sync and async helpers.
Notes
The manager stores one project-wide settings payload in a single
Redis hash identified by site_settings.
Source code in src/codex_django/core/redis/managers/settings.py
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 | |
Functions
aload_cached(model_cls)
async
Load cached site settings from Redis asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_cls
|
type[Model]
|
Django model class for the concrete site settings
model. The argument is accepted for API symmetry with
:meth: |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Cached settings data, or an empty dictionary when caching is |
dict[str, Any]
|
disabled or no Redis entry exists. |
Source code in src/codex_django/core/redis/managers/settings.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
load_cached(model_cls)
Load cached settings or fall back to the first database row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_cls
|
type[Model]
|
Django model class that stores the singleton site
settings payload and optionally implements |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Cached or freshly loaded site settings data. |
Source code in src/codex_django/core/redis/managers/settings.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
asave_instance(instance)
async
Persist a settings instance to Redis asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
Model
|
Concrete site settings model instance that implements
|
required |
Source code in src/codex_django/core/redis/managers/settings.py
95 96 97 98 99 100 101 102 103 104 105 106 | |
save_instance(instance)
Synchronously persist a settings instance to Redis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
Model
|
Concrete site settings model instance that implements
|
required |
Source code in src/codex_django/core/redis/managers/settings.py
108 109 110 111 112 113 114 115 | |
Functions
get_site_settings_manager()
Return a site settings manager configured from Django settings.
Returns:
| Type | Description |
|---|---|
DjangoSiteSettingsManager
|
A ready-to-use :class: |
Source code in src/codex_django/core/redis/managers/settings.py
118 119 120 121 122 123 124 | |
Redis SEO manager
codex_django.core.redis.managers.seo
Redis manager for cached static-page SEO payloads.
Classes
SeoRedisManager
Bases: BaseDjangoRedisManager
Manage cached SEO payloads for static pages.
Notes
SEO data is stored as a Redis hash per page key so templates and selectors can read the payload without repeated database hits.
Source code in src/codex_django/core/redis/managers/seo.py
10 11 12 13 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 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 | |
Functions
aget_page(page_key)
async
Return cached SEO data for a page as a flat string mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_key
|
str
|
Logical page identifier used by the SEO model. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
A flat string mapping for the page, or an empty dictionary when |
dict[str, str]
|
no cache entry exists. |
Source code in src/codex_django/core/redis/managers/seo.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
aset_page(page_key, mapping, timeout=None)
async
Store SEO data for a page in a Redis hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_key
|
str
|
Logical page identifier used by the SEO model. |
required |
mapping
|
dict[str, str]
|
Flat string payload to cache. |
required |
timeout
|
int | None
|
Optional TTL in seconds. |
None
|
Source code in src/codex_django/core/redis/managers/seo.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
ainvalidate_page(page_key)
async
Delete the cached SEO payload for a specific page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_key
|
str
|
Logical page identifier used by the SEO model. |
required |
Source code in src/codex_django/core/redis/managers/seo.py
51 52 53 54 55 56 57 58 59 | |
get_page(page_key)
Synchronously return cached SEO data for a page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_key
|
str
|
Logical page identifier used by the SEO model. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
A flat string mapping for the page, or an empty dictionary when |
dict[str, str]
|
no cache entry exists. |
Source code in src/codex_django/core/redis/managers/seo.py
61 62 63 64 65 66 67 68 69 70 71 | |
set_page(page_key, mapping, timeout=None)
Synchronously cache SEO data for a page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_key
|
str
|
Logical page identifier used by the SEO model. |
required |
mapping
|
dict[str, str]
|
Flat string payload to cache. |
required |
timeout
|
int | None
|
Optional TTL in seconds. |
None
|
Source code in src/codex_django/core/redis/managers/seo.py
73 74 75 76 77 78 79 80 81 | |
invalidate_page(page_key)
Synchronously invalidate SEO cache for a page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_key
|
str
|
Logical page identifier used by the SEO model. |
required |
Source code in src/codex_django/core/redis/managers/seo.py
83 84 85 86 87 88 89 | |
Functions
get_seo_redis_manager()
Return an SEO Redis manager configured from Django settings.
Returns:
| Type | Description |
|---|---|
SeoRedisManager
|
A ready-to-use :class: |
Source code in src/codex_django/core/redis/managers/seo.py
92 93 94 95 96 97 98 | |
Redis notifications manager
codex_django.core.redis.managers.notifications
Redis manager for lightweight notification-related cache entries.
Classes
NotificationsCacheManager
Bases: BaseDjangoRedisManager
Read and write notification-related cache entries in Redis.
Notes
This manager is intentionally generic and stores simple key/value entries for notification subjects, templates, or other derived metadata that benefits from Redis-backed reuse.
Source code in src/codex_django/core/redis/managers/notifications.py
10 11 12 13 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 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 | |
Functions
aget(key)
async
Return a cached notification value by key, if present.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Logical cache key inside the notification namespace. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The cached string value or |
Source code in src/codex_django/core/redis/managers/notifications.py
22 23 24 25 26 27 28 29 30 31 32 33 | |
aset(key, value, timeout=None)
async
Store a notification cache value with an optional TTL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Logical cache key inside the notification namespace. |
required |
value
|
Any
|
Value to store in Redis. |
required |
timeout
|
int | None
|
Optional TTL in seconds. |
None
|
Source code in src/codex_django/core/redis/managers/notifications.py
35 36 37 38 39 40 41 42 43 44 45 | |
get(key)
Synchronously return a cached notification value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Logical cache key inside the notification namespace. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The cached string value or |
Source code in src/codex_django/core/redis/managers/notifications.py
47 48 49 50 51 52 53 54 55 56 | |
set(key, value, timeout=None)
Synchronously store a notification cache value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Logical cache key inside the notification namespace. |
required |
value
|
Any
|
Value to store in Redis. |
required |
timeout
|
int | None
|
Optional TTL in seconds. |
None
|
Source code in src/codex_django/core/redis/managers/notifications.py
58 59 60 61 62 63 64 65 66 | |
Functions
get_notifications_cache_manager()
Return a notifications cache manager configured from Django settings.
Returns:
| Type | Description |
|---|---|
NotificationsCacheManager
|
A ready-to-use :class: |
Source code in src/codex_django/core/redis/managers/notifications.py
69 70 71 72 73 74 75 | |
Redis booking manager
codex_django.core.redis.managers.booking
codex_django.core.redis.managers.booking
Redis cache manager for booking busy slot intervals.
Caches busy intervals (not free slots) per master per date. ChainFinder computes free slots on the fly — cheap math when busy data is in memory.
Invalidation is surgical: master_id + date.
Classes
BookingCacheManager
Bases: BaseDjangoRedisManager
Cache for busy slot intervals.
Notes
Key format: booking:busy:{master_id}:{date}
Value: JSON list of [[start_iso, end_iso], ...]
Source code in src/codex_django/core/redis/managers/booking.py
20 21 22 23 24 25 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 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 | |
Functions
aget_busy(master_id, date_str)
async
Return cached busy intervals for a master on a date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
master_id
|
str
|
Resource identifier used in booking availability. |
required |
date_str
|
str
|
ISO-like date string for the cached day bucket. |
required |
Returns:
| Type | Description |
|---|---|
list[list[str]] | None
|
Cached intervals or |
Source code in src/codex_django/core/redis/managers/booking.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
aset_busy(master_id, date_str, intervals, timeout=300)
async
Store busy intervals for one resource-day pair in cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
master_id
|
str
|
Resource identifier used in booking availability. |
required |
date_str
|
str
|
ISO-like date string for the cached day bucket. |
required |
intervals
|
list[list[str]]
|
Busy intervals encoded as |
required |
timeout
|
int
|
Cache lifetime in seconds. |
300
|
Source code in src/codex_django/core/redis/managers/booking.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
ainvalidate_master_date(master_id, date_str)
async
Delete cached busy intervals for a specific resource-day pair.
Source code in src/codex_django/core/redis/managers/booking.py
72 73 74 75 76 | |
get_busy(master_id, date_str)
Synchronously return cached busy intervals for a resource-day pair.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
master_id
|
str
|
Resource identifier used in booking availability. |
required |
date_str
|
str
|
ISO-like date string for the cached day bucket. |
required |
Returns:
| Type | Description |
|---|---|
list[list[str]] | None
|
Cached intervals or |
Source code in src/codex_django/core/redis/managers/booking.py
82 83 84 85 86 87 88 89 90 91 92 | |
set_busy(master_id, date_str, intervals, timeout=300)
Synchronously store busy intervals for one resource-day pair.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
master_id
|
str
|
Resource identifier used in booking availability. |
required |
date_str
|
str
|
ISO-like date string for the cached day bucket. |
required |
intervals
|
list[list[str]]
|
Busy intervals encoded as |
required |
timeout
|
int
|
Cache lifetime in seconds. |
300
|
Source code in src/codex_django/core/redis/managers/booking.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
invalidate_master_date(master_id, date_str)
Synchronously invalidate busy-slot cache for one resource-day pair.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
master_id
|
str
|
Resource identifier used in booking availability. |
required |
date_str
|
str
|
ISO-like date string for the cached day bucket. |
required |
Source code in src/codex_django/core/redis/managers/booking.py
111 112 113 114 115 116 117 118 | |
Functions
get_booking_cache_manager()
Return a booking cache manager configured from Django settings.
Returns:
| Type | Description |
|---|---|
BookingCacheManager
|
A ready-to-use :class: |
Source code in src/codex_django/core/redis/managers/booking.py
121 122 123 124 125 126 127 | |