cardo-python-utils 0.5.dev40__tar.gz → 0.5.dev42__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cardo_python_utils-0.5.dev40/cardo_python_utils.egg-info → cardo_python_utils-0.5.dev42}/PKG-INFO +1 -1
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42/cardo_python_utils.egg-info}/PKG-INFO +1 -1
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/pyproject.toml +1 -1
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/api/utils.py +3 -4
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/settings.py +1 -2
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/tenant_context.py +2 -2
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/LICENSE +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/MANIFEST.in +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/README.rst +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/cardo_python_utils.egg-info/SOURCES.txt +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/cardo_python_utils.egg-info/dependency_links.txt +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/cardo_python_utils.egg-info/requires.txt +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/cardo_python_utils.egg-info/top_level.txt +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/__init__.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/choices.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/data_structures.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/db.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/README.md +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/__init__.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/admin/__init__.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/admin/auth.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/admin/templates/__init__.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/admin/templates/user_groups_changelist.html +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/admin/user_group.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/admin/views.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/api/__init__.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/api/drf.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/api/ninja.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/apps.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/auth/service.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/celery/__init__.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/celery/tenant_aware_database_scheduler.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/celery/tenant_aware_task.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/db/__init__.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/db/routers.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/db/transaction.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/db/utils.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/management/__init__.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/management/commands/__init__.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/management/commands/migrateall.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/management/commands/tenant_aware_command.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/middleware/__init__.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/middleware/tenant_aware_http_middleware.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/middleware/tenant_aware_websocket_middleware.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/models/__init__.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/models/user_group.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/oidc_settings.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/redis/__init__.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/redis/key_function.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/storage/__init__.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/storage/tenant_aware_storage.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/tests/__init__.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/tests/conftest.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django_utils.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/esma_choices.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/exceptions.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/imports.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/math.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/text.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/time.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/types_hinting.py +0 -0
- {cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/setup.cfg +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cardo-python-utils"
|
|
7
|
-
version = "0.5.
|
|
7
|
+
version = "0.5.dev42"
|
|
8
8
|
description = "Python library enhanced with a wide range of functions for different scenarios."
|
|
9
9
|
readme = "README.rst"
|
|
10
10
|
requires-python = ">=3.8"
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/api/utils.py
RENAMED
|
@@ -20,9 +20,6 @@ def get_jwks_client():
|
|
|
20
20
|
return JWKS_CLIENTS[tenant]
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
User = get_user_model()
|
|
24
|
-
|
|
25
|
-
|
|
26
23
|
class TokenPayload(TypedDict, total=False):
|
|
27
24
|
exp: int
|
|
28
25
|
iat: int
|
|
@@ -75,7 +72,7 @@ def get_user_data_from_payload(payload: TokenPayload) -> dict:
|
|
|
75
72
|
"is_staff": payload.get("is_staff", False),
|
|
76
73
|
}
|
|
77
74
|
|
|
78
|
-
if hasattr(
|
|
75
|
+
if hasattr(get_user_model(), "is_demo"):
|
|
79
76
|
user_data["is_demo"] = payload.get("is_demo", False)
|
|
80
77
|
|
|
81
78
|
return user_data
|
|
@@ -96,6 +93,7 @@ def create_or_update_user(username: str, payload: TokenPayload):
|
|
|
96
93
|
"""
|
|
97
94
|
Create or update a user based on the JWT payload.
|
|
98
95
|
"""
|
|
96
|
+
User = get_user_model()
|
|
99
97
|
user_data = get_user_data_from_payload(payload)
|
|
100
98
|
|
|
101
99
|
user = User.objects.filter(username=username).first()
|
|
@@ -114,6 +112,7 @@ def create_or_update_user(username: str, payload: TokenPayload):
|
|
|
114
112
|
|
|
115
113
|
|
|
116
114
|
async def acreate_or_update_user(username: str, payload: TokenPayload):
|
|
115
|
+
User = get_user_model()
|
|
117
116
|
user_data = get_user_data_from_payload(payload)
|
|
118
117
|
|
|
119
118
|
user = await User.objects.filter(username=username).afirst()
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/settings.py
RENAMED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from django.conf import settings
|
|
2
2
|
|
|
3
3
|
TENANT_KEY = "tenant"
|
|
4
|
-
DATABASES = settings.DATABASES
|
|
5
4
|
TENANT_DATABASES = set(settings.DATABASES.keys()) - {"default"}
|
|
6
5
|
|
|
7
6
|
TENANT_AWARE_EXCLUDED_PATHS = getattr(settings, "TENANT_AWARE_EXCLUDED_PATHS", ())
|
|
@@ -20,4 +19,4 @@ if DEVELOPMENT_TENANT is None:
|
|
|
20
19
|
if TENANT_DATABASES:
|
|
21
20
|
DEVELOPMENT_TENANT = list(TENANT_DATABASES)[0]
|
|
22
21
|
else:
|
|
23
|
-
DEVELOPMENT_TENANT = list(DATABASES.keys())[0]
|
|
22
|
+
DEVELOPMENT_TENANT = list(settings.DATABASES.keys())[0]
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/tenant_context.py
RENAMED
|
@@ -3,7 +3,7 @@ from contextlib import ContextDecorator
|
|
|
3
3
|
from contextvars import ContextVar
|
|
4
4
|
from typing import Optional
|
|
5
5
|
|
|
6
|
-
from .
|
|
6
|
+
from django.conf import settings
|
|
7
7
|
|
|
8
8
|
logger = logging.getLogger(__name__)
|
|
9
9
|
|
|
@@ -84,7 +84,7 @@ class TenantContext(ContextDecorator):
|
|
|
84
84
|
# If the tenant is already set to the same value, we do nothing and return None.
|
|
85
85
|
return None
|
|
86
86
|
|
|
87
|
-
if tenant not in DATABASES:
|
|
87
|
+
if tenant not in settings.DATABASES:
|
|
88
88
|
raise ValueError(f"Tenant '{tenant}' not found in DATABASES settings.")
|
|
89
89
|
|
|
90
90
|
token = _tenant_var.set(tenant)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/data_structures.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/__init__.py
RENAMED
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/admin/__init__.py
RENAMED
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/admin/auth.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/admin/views.py
RENAMED
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/api/__init__.py
RENAMED
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/api/drf.py
RENAMED
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/api/ninja.py
RENAMED
|
File without changes
|
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/auth/service.py
RENAMED
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/celery/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/db/__init__.py
RENAMED
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/db/routers.py
RENAMED
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/db/transaction.py
RENAMED
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/db/utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/models/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/oidc_settings.py
RENAMED
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/redis/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/tests/__init__.py
RENAMED
|
File without changes
|
{cardo_python_utils-0.5.dev40 → cardo_python_utils-0.5.dev42}/python_utils/django/tests/conftest.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|