maquinaweb-shared-auth 0.2.37__py3-none-any.whl → 0.2.39__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.
Potentially problematic release.
This version of maquinaweb-shared-auth might be problematic. Click here for more details.
- {maquinaweb_shared_auth-0.2.37.dist-info → maquinaweb_shared_auth-0.2.39.dist-info}/METADATA +1 -1
- {maquinaweb_shared_auth-0.2.37.dist-info → maquinaweb_shared_auth-0.2.39.dist-info}/RECORD +7 -7
- shared_auth/mixins.py +24 -3
- shared_auth/serializers.py +19 -19
- shared_auth/utils.py +8 -4
- {maquinaweb_shared_auth-0.2.37.dist-info → maquinaweb_shared_auth-0.2.39.dist-info}/WHEEL +0 -0
- {maquinaweb_shared_auth-0.2.37.dist-info → maquinaweb_shared_auth-0.2.39.dist-info}/top_level.txt +0 -0
|
@@ -8,16 +8,16 @@ shared_auth/exceptions.py,sha256=VKamHjBl2yjXG2RsMrLrXru1_Q9IJXmy4xmDcXlpWsU,627
|
|
|
8
8
|
shared_auth/fields.py,sha256=RAcmFh1D_nkbai_7t_OrPZhfhAipesy5kKnEj4LUvvM,1254
|
|
9
9
|
shared_auth/managers.py,sha256=OQd76OeAkeyRoFnifQ0zZdp45h27QVwBpR0BgiiTFbQ,6968
|
|
10
10
|
shared_auth/middleware.py,sha256=A8yc8Ld4EslEcPCdekfCrU7eAXgql_AntYjy1xMchu8,6335
|
|
11
|
-
shared_auth/mixins.py,sha256=
|
|
11
|
+
shared_auth/mixins.py,sha256=NsLF49ca8EFyXLFmmRLkCKMmoKFMUqA37PYar2h9wB4,8321
|
|
12
12
|
shared_auth/models.py,sha256=HCVIog61J0xeygYIs_amSA-MsSRhxIlGTSkegA9b51c,1444
|
|
13
13
|
shared_auth/permissions.py,sha256=l48n9qCUMrhQOTa5_Cv1vynv-bb3i5T05yLoyKvKmOM,2713
|
|
14
14
|
shared_auth/router.py,sha256=JhlDjosViMBmuvYm08vJzKyvrg5P5ECtrU4tKAGsuoU,684
|
|
15
|
-
shared_auth/serializers.py,sha256=
|
|
15
|
+
shared_auth/serializers.py,sha256=CnnkBeI08KnwD5y2eGpcdQDQNR0FyGn958L6V5LpGtg,14266
|
|
16
16
|
shared_auth/storage_backend.py,sha256=Eqkjz8aF5UrOpRwYl-J0Td95IObfxnJ8eLQDJVFM3Io,184
|
|
17
17
|
shared_auth/urls.py,sha256=591wWEWJPaHEGkcOZ8yvfgxddRyOcZLgOc0vNtF7XRI,289
|
|
18
|
-
shared_auth/utils.py,sha256=
|
|
18
|
+
shared_auth/utils.py,sha256=E3Ox5FA1D6OHfesZV8Z5D-T4h-zhpHbiHQYfdmRDH8U,4119
|
|
19
19
|
shared_auth/views.py,sha256=2hyLnYSWUscfq-jVcskt-ukzDt4vg6IXeKjRDRu9RXk,1519
|
|
20
|
-
maquinaweb_shared_auth-0.2.
|
|
21
|
-
maquinaweb_shared_auth-0.2.
|
|
22
|
-
maquinaweb_shared_auth-0.2.
|
|
23
|
-
maquinaweb_shared_auth-0.2.
|
|
20
|
+
maquinaweb_shared_auth-0.2.39.dist-info/METADATA,sha256=GxK5Ecy3QwgnwD3mamos98wGTbAahNqLUdwkzduDqcc,26325
|
|
21
|
+
maquinaweb_shared_auth-0.2.39.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
22
|
+
maquinaweb_shared_auth-0.2.39.dist-info/top_level.txt,sha256=msyYRy02ZV7zz7GR1raUI5LXGFIFn2TIkgkeKZqKufE,12
|
|
23
|
+
maquinaweb_shared_auth-0.2.39.dist-info/RECORD,,
|
shared_auth/mixins.py
CHANGED
|
@@ -38,11 +38,26 @@ class OrganizationMixin(models.Model):
|
|
|
38
38
|
models.Index(fields=["organization_id"]),
|
|
39
39
|
]
|
|
40
40
|
|
|
41
|
+
@classmethod
|
|
42
|
+
def prefetch_organizations(cls, queryset, request):
|
|
43
|
+
if not hasattr(request, "_orgs_dict"):
|
|
44
|
+
from shared_auth.utils import get_organization_model
|
|
45
|
+
|
|
46
|
+
Organization = get_organization_model()
|
|
47
|
+
org_ids = list(
|
|
48
|
+
queryset.values_list("organization_id", flat=True).distinct()
|
|
49
|
+
)
|
|
50
|
+
if not org_ids:
|
|
51
|
+
request._orgs_dict = {}
|
|
52
|
+
return queryset
|
|
53
|
+
|
|
54
|
+
orgs_qs = Organization.objects.filter(pk__in=org_ids)
|
|
55
|
+
request._orgs_dict = {org.pk: org for org in orgs_qs}
|
|
56
|
+
|
|
57
|
+
return queryset
|
|
58
|
+
|
|
41
59
|
@property
|
|
42
60
|
def organization(self):
|
|
43
|
-
"""
|
|
44
|
-
Acessa organização do banco de auth (lazy loading com cache)
|
|
45
|
-
"""
|
|
46
61
|
if not hasattr(self, "_cached_organization"):
|
|
47
62
|
from shared_auth.utils import get_organization_model
|
|
48
63
|
|
|
@@ -251,6 +266,12 @@ class LoggedOrganizationMixin(viewsets.ModelViewSet):
|
|
|
251
266
|
serializer.save()
|
|
252
267
|
|
|
253
268
|
|
|
269
|
+
class PrefetchOrganizationsMixin(LoggedOrganizationMixin):
|
|
270
|
+
def get_queryset(self):
|
|
271
|
+
queryset = super().get_queryset()
|
|
272
|
+
return OrganizationMixin.prefetch_organizations(queryset, self.request)
|
|
273
|
+
|
|
274
|
+
|
|
254
275
|
class TimestampedMixin(models.Model):
|
|
255
276
|
"""
|
|
256
277
|
Mixin para adicionar timestamps
|
shared_auth/serializers.py
CHANGED
|
@@ -79,25 +79,25 @@ class OrganizationSerializerMixin(serializers.ModelSerializer):
|
|
|
79
79
|
organization = serializers.SerializerMethodField()
|
|
80
80
|
|
|
81
81
|
def get_organization(self, obj):
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
82
|
+
req = self.context.get("request")
|
|
83
|
+
org = getattr(req, "_orgs_dict", {}).get(obj.organization_id) if req else None
|
|
84
|
+
return self._serialize_org(org) if org else None
|
|
85
|
+
|
|
86
|
+
def _serialize_org(self, org):
|
|
87
|
+
return {
|
|
88
|
+
"id": org.pk,
|
|
89
|
+
"name": org.name,
|
|
90
|
+
"fantasy_name": org.fantasy_name,
|
|
91
|
+
"image_organization": org.image_organization.url
|
|
92
|
+
if org.image_organization
|
|
93
|
+
else None,
|
|
94
|
+
"cnpj": org.cnpj,
|
|
95
|
+
"email": org.email,
|
|
96
|
+
"telephone": org.telephone,
|
|
97
|
+
"cellphone": org.cellphone,
|
|
98
|
+
"is_branch": org.is_branch,
|
|
99
|
+
"is_active": org.is_active(),
|
|
100
|
+
}
|
|
101
101
|
|
|
102
102
|
|
|
103
103
|
class OrganizationListCreateSerializerMixin(
|
shared_auth/utils.py
CHANGED
|
@@ -118,12 +118,16 @@ def get_member_model():
|
|
|
118
118
|
|
|
119
119
|
|
|
120
120
|
def get_organization_serializer():
|
|
121
|
-
|
|
121
|
+
import_path_serializer = get_setting("SHARED_AUTH_ORGANIZATION_SERIALIZER", None)
|
|
122
122
|
|
|
123
|
-
if not
|
|
123
|
+
if not import_path_serializer:
|
|
124
124
|
return serializers.ModelSerializer
|
|
125
125
|
|
|
126
126
|
try:
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
module_path, class_name = import_path_serializer.rsplit(".", 1)
|
|
128
|
+
module = importlib.import_module(module_path)
|
|
129
|
+
serializer_class = getattr(module, class_name)
|
|
130
|
+
return serializer_class
|
|
131
|
+
except Exception as e:
|
|
132
|
+
print(f"Erro ao importar serializer: {import_path_serializer}: {e}")
|
|
129
133
|
return serializers.ModelSerializer
|
|
File without changes
|
{maquinaweb_shared_auth-0.2.37.dist-info → maquinaweb_shared_auth-0.2.39.dist-info}/top_level.txt
RENAMED
|
File without changes
|