oxutils 0.1.10__py3-none-any.whl → 0.1.11__py3-none-any.whl
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.
- oxutils/jwt/auth.py +1 -1
- oxutils/oxiliere/caches.py +2 -3
- oxutils/oxiliere/context.py +2 -4
- oxutils/oxiliere/management/commands/init_oxiliere_system.py +12 -5
- oxutils/oxiliere/utils.py +3 -7
- {oxutils-0.1.10.dist-info → oxutils-0.1.11.dist-info}/METADATA +1 -1
- {oxutils-0.1.10.dist-info → oxutils-0.1.11.dist-info}/RECORD +8 -8
- {oxutils-0.1.10.dist-info → oxutils-0.1.11.dist-info}/WHEEL +0 -0
oxutils/jwt/auth.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from typing import Dict, Any, Optional, Type, Tuple
|
|
2
|
+
from typing import Dict, Any, Optional, Type, Tuple, List
|
|
3
3
|
from django.utils.translation import gettext_lazy as _
|
|
4
4
|
from django.http import HttpRequest
|
|
5
5
|
from django.contrib.auth.models import AbstractUser
|
oxutils/oxiliere/caches.py
CHANGED
|
@@ -3,7 +3,7 @@ from cacheops import cached_as, cached
|
|
|
3
3
|
from oxutils.oxiliere.utils import (
|
|
4
4
|
get_tenant_model,
|
|
5
5
|
get_tenant_user_model,
|
|
6
|
-
|
|
6
|
+
get_system_tenant_oxi_id
|
|
7
7
|
)
|
|
8
8
|
|
|
9
9
|
|
|
@@ -33,5 +33,4 @@ def get_tenant_user(oxi_org_id: str, oxi_user_id: str):
|
|
|
33
33
|
|
|
34
34
|
@cached(timeout=60*15)
|
|
35
35
|
def get_system_tenant():
|
|
36
|
-
|
|
37
|
-
return get_tenant_model().objects.get(schema_name=schema_name)
|
|
36
|
+
return get_tenant_model().objects.get(oxi_id=get_system_tenant_oxi_id())
|
oxutils/oxiliere/context.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import contextvars
|
|
2
|
-
from oxutils.oxiliere.utils import
|
|
2
|
+
from oxutils.oxiliere.utils import get_system_tenant_oxi_id
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
current_tenant_schema_name: contextvars.ContextVar[str] = contextvars.ContextVar(
|
|
6
6
|
"current_tenant_schema_name",
|
|
7
|
-
default=
|
|
7
|
+
default=f"[oxi_id] {get_system_tenant_oxi_id()}"
|
|
8
8
|
)
|
|
9
9
|
|
|
10
10
|
|
|
@@ -14,5 +14,3 @@ def get_current_tenant_schema_name() -> str:
|
|
|
14
14
|
|
|
15
15
|
def set_current_tenant_schema_name(schema_name: str):
|
|
16
16
|
current_tenant_schema_name.set(schema_name)
|
|
17
|
-
|
|
18
|
-
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import uuid
|
|
2
2
|
from django.core.management.base import BaseCommand
|
|
3
3
|
from django.conf import settings
|
|
4
|
-
from django.db import transaction
|
|
4
|
+
from django.db import transaction, connection
|
|
5
5
|
from django.contrib.auth import get_user_model
|
|
6
6
|
from django_tenants.utils import (
|
|
7
7
|
get_tenant_model,
|
|
8
|
-
get_tenant_domain_model
|
|
8
|
+
get_tenant_domain_model,
|
|
9
9
|
)
|
|
10
10
|
from oxutils.oxiliere.utils import (
|
|
11
11
|
oxid_to_schema_name,
|
|
@@ -16,7 +16,7 @@ from oxutils.oxiliere.constants import (
|
|
|
16
16
|
OXI_SYSTEM_DOMAIN,
|
|
17
17
|
OXI_SYSTEM_OWNER_EMAIL
|
|
18
18
|
)
|
|
19
|
-
|
|
19
|
+
from oxutils.oxiliere.authorization import grant_manager_access_to_owners
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
@@ -38,8 +38,8 @@ class Command(BaseCommand):
|
|
|
38
38
|
self.stdout.write(self.style.WARNING(f'Initialisation du tenant système...'))
|
|
39
39
|
|
|
40
40
|
# Vérifier si le tenant système existe déjà
|
|
41
|
-
if TenantModel.objects.filter(
|
|
42
|
-
self.stdout.write(self.style.ERROR(f'Le tenant système "{
|
|
41
|
+
if TenantModel.objects.filter(oxi_id=system_slug).exists():
|
|
42
|
+
self.stdout.write(self.style.ERROR(f'Le tenant système "{system_slug}" existe déjà!'))
|
|
43
43
|
return
|
|
44
44
|
|
|
45
45
|
# Créer le tenant système
|
|
@@ -62,6 +62,8 @@ class Command(BaseCommand):
|
|
|
62
62
|
is_primary=True
|
|
63
63
|
)
|
|
64
64
|
self.stdout.write(self.style.SUCCESS(f'✓ Domaine créé: {domain.domain}'))
|
|
65
|
+
|
|
66
|
+
connection.set_tenant(tenant)
|
|
65
67
|
|
|
66
68
|
self.stdout.write(f'Création du superuser: {owner_email}')
|
|
67
69
|
try:
|
|
@@ -88,6 +90,11 @@ class Command(BaseCommand):
|
|
|
88
90
|
)
|
|
89
91
|
if created:
|
|
90
92
|
self.stdout.write(self.style.SUCCESS(f'✓ Superuser lié au tenant système'))
|
|
93
|
+
try:
|
|
94
|
+
grant_manager_access_to_owners(tenant)
|
|
95
|
+
self.stdout.write(self.style.SUCCESS(f'✓ Droits mis en place'))
|
|
96
|
+
except Exception as e:
|
|
97
|
+
self.stdout.write(self.style.ERROR(f'Erreur lors de la mise en place des droits: {str(e)}'))
|
|
91
98
|
else:
|
|
92
99
|
self.stdout.write(self.style.WARNING(f'⚠ Liaison existe déjà'))
|
|
93
100
|
|
oxutils/oxiliere/utils.py
CHANGED
|
@@ -23,14 +23,10 @@ def get_tenant_user_model() -> Any:
|
|
|
23
23
|
return get_model('TENANT_USER_MODEL')
|
|
24
24
|
|
|
25
25
|
def is_system_tenant(tenant: Any) -> bool:
|
|
26
|
-
return tenant.
|
|
26
|
+
return tenant.oxi_id == get_system_tenant_oxi_id()
|
|
27
27
|
|
|
28
|
-
def
|
|
29
|
-
|
|
30
|
-
getattr(settings, 'OXI_SYSTEM_TENANT', OXI_SYSTEM_TENANT)
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
return system_schema_name
|
|
28
|
+
def get_system_tenant_oxi_id():
|
|
29
|
+
return getattr(settings, 'OXI_SYSTEM_TENANT', OXI_SYSTEM_TENANT)
|
|
34
30
|
|
|
35
31
|
def oxid_to_schema_name(oxid: str) -> str:
|
|
36
32
|
"""
|
|
@@ -33,7 +33,7 @@ oxutils/enums/invoices.py,sha256=E33QGQeutZUqvlovJY0VGDxWUb0i_kdfhEiir1ARKuQ,201
|
|
|
33
33
|
oxutils/exceptions.py,sha256=CCjENOD0of6_noif2ajrpfbBLoG16DWa46iB9_uEe3M,3592
|
|
34
34
|
oxutils/functions.py,sha256=4stHj94VebWX0s1XeWshubMD2v8w8QztTWppbkTE_Gg,3246
|
|
35
35
|
oxutils/jwt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
36
|
-
oxutils/jwt/auth.py,sha256=
|
|
36
|
+
oxutils/jwt/auth.py,sha256=h3rm7nSEweMgyzy5HBRwqC1gPvZ-EZuwdJISSvnltXY,6349
|
|
37
37
|
oxutils/jwt/models.py,sha256=Q0zRnWpK0trFoPDv5ZEY2ROCRaNn83W-K8SbrmSg1E8,2122
|
|
38
38
|
oxutils/jwt/tokens.py,sha256=kWgtPl4XxV0xHkjbhd5QteQy8Wv5MsvyLcLVyO-gzuo,1822
|
|
39
39
|
oxutils/jwt/utils.py,sha256=Wuy-PnCcUw6MpY6z1Isy2vOx-_u1o6LjUfRJgf_cqbY,1202
|
|
@@ -55,17 +55,17 @@ oxutils/oxiliere/admin.py,sha256=suMo4x8I3JBxAFBVIdE-5qnqZ6JAZV0FESABHOSc-vg,63
|
|
|
55
55
|
oxutils/oxiliere/apps.py,sha256=sPZFBFyCM7nbvDdIv15VbdPLl_-Apm1OsaaByfGpP3o,327
|
|
56
56
|
oxutils/oxiliere/authorization.py,sha256=52-ch4T443sC1ZdXvYgzgbQRfotVyQJbfna5-ubBnFM,1408
|
|
57
57
|
oxutils/oxiliere/cacheops.py,sha256=VGG5qG5IsxvWJTu1aTlmsaDXV2aiuIMVdVcvHGHeY3g,163
|
|
58
|
-
oxutils/oxiliere/caches.py,sha256=
|
|
58
|
+
oxutils/oxiliere/caches.py,sha256=y1UxBRL9N8xQzN5BYRyIGaNqmbro4_YblcCtOp5BD38,890
|
|
59
59
|
oxutils/oxiliere/checks.py,sha256=fV1DCdLmtL35CUCsisyCf4FRw8yZMl66ntpuksrjoL8,930
|
|
60
60
|
oxutils/oxiliere/constants.py,sha256=IMLhZN7rWHooE9Y9nB4nYsDticNuUscvgvEPUScG58M,125
|
|
61
|
-
oxutils/oxiliere/context.py,sha256=
|
|
61
|
+
oxutils/oxiliere/context.py,sha256=TZ_dNlYhpdSG8r8MNjv75SA8dTUEw2hdZ8fMkW0zEmU,447
|
|
62
62
|
oxutils/oxiliere/controllers.py,sha256=hL_snutY1EuSO0n06NDbjkz-3A3hkqa3sYGie3Grbmg,847
|
|
63
63
|
oxutils/oxiliere/enums.py,sha256=etpHgzsHTQKMrPIxVH-d592_DYSRJ2_o0c8bOdIza-8,201
|
|
64
64
|
oxutils/oxiliere/exceptions.py,sha256=d-J-beEend4L49SJcoGRO7SKLyxlQeuLkLnFU5oTCPQ,178
|
|
65
65
|
oxutils/oxiliere/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
66
66
|
oxutils/oxiliere/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
67
67
|
oxutils/oxiliere/management/commands/grant_tenant_owners.py,sha256=U0tc-b677kEFA7KC6xah3Ufbg6qYkW21nRikC0FJRQI,774
|
|
68
|
-
oxutils/oxiliere/management/commands/init_oxiliere_system.py,sha256=
|
|
68
|
+
oxutils/oxiliere/management/commands/init_oxiliere_system.py,sha256=7ZmKOwL2TOIaPYBpGEoqcw2XslpG1VikUnTJwpu84Lo,4247
|
|
69
69
|
oxutils/oxiliere/middleware.py,sha256=c0C1aalshhYNfe4SBglJkWfUo4Ct-d391GoWP_NhPOw,6412
|
|
70
70
|
oxutils/oxiliere/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
71
71
|
oxutils/oxiliere/models.py,sha256=dN3q-8W2gUcUra49b3R33o0ZNn3stc-pfkoVMAKR4gE,6260
|
|
@@ -74,7 +74,7 @@ oxutils/oxiliere/schemas.py,sha256=eV9MzkIpHFHmZFtv8Ck2xaGoVUDJXr-yl7w50U-Tj_8,2
|
|
|
74
74
|
oxutils/oxiliere/settings.py,sha256=ZuKppEyrucWxvvYC2-wLap4RzKfaEfaRdjJnsNZzpuY,440
|
|
75
75
|
oxutils/oxiliere/signals.py,sha256=il6twTzbmv14SxukLx7dLw2QzuNDyVAsIgHmqbYspjw,97
|
|
76
76
|
oxutils/oxiliere/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
|
|
77
|
-
oxutils/oxiliere/utils.py,sha256=
|
|
77
|
+
oxutils/oxiliere/utils.py,sha256=3Q7c_KFiw3iRrGtP8mVtWpuPqCzS4YFmM6V69BIeHvg,3403
|
|
78
78
|
oxutils/pagination/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
79
79
|
oxutils/pagination/cursor.py,sha256=l1KuKnILkN96JSoDRJGwiXIpdjxSk-tqQhJREK1TBUM,13159
|
|
80
80
|
oxutils/pdf/__init__.py,sha256=Uu_yOEd-FcNHIB7CV6y76c53wjL5Hce2GMjho8gnkbM,236
|
|
@@ -120,6 +120,6 @@ oxutils/users/models.py,sha256=y5SF5tSqri11LRqRBDorSv5IYRa7noBHjFqQUJ5Jkkg,3105
|
|
|
120
120
|
oxutils/users/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
|
|
121
121
|
oxutils/users/utils.py,sha256=jY-zL8vLT5U3E2FV3DqCvrPORjKLutbkPZTQ-z96dCw,376
|
|
122
122
|
oxutils/utils.py,sha256=6yGX2d1ajU5RqgfqiaS4McYm7ip2KEgADABo3M-yA3U,595
|
|
123
|
-
oxutils-0.1.
|
|
124
|
-
oxutils-0.1.
|
|
125
|
-
oxutils-0.1.
|
|
123
|
+
oxutils-0.1.11.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
124
|
+
oxutils-0.1.11.dist-info/METADATA,sha256=9V6IvUcbPq-tFiBMHMK4rMurzifue-WYnH7arQtqSYk,8760
|
|
125
|
+
oxutils-0.1.11.dist-info/RECORD,,
|
|
File without changes
|