maquinaweb-shared-auth 0.2.38__tar.gz → 0.2.40__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.
Potentially problematic release.
This version of maquinaweb-shared-auth might be problematic. Click here for more details.
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/PKG-INFO +1 -1
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/maquinaweb_shared_auth.egg-info/PKG-INFO +1 -1
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/pyproject.toml +1 -1
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/mixins.py +25 -3
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/serializers.py +21 -19
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/README.md +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/maquinaweb_shared_auth.egg-info/SOURCES.txt +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/maquinaweb_shared_auth.egg-info/dependency_links.txt +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/maquinaweb_shared_auth.egg-info/requires.txt +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/maquinaweb_shared_auth.egg-info/top_level.txt +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/setup.cfg +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/setup.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/__init__.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/abstract_models.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/app.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/authentication.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/conf.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/decorators.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/exceptions.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/fields.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/managers.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/middleware.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/models.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/permissions.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/router.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/storage_backend.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/urls.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/utils.py +0 -0
- {maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/views.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "maquinaweb-shared-auth"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.40"
|
|
8
8
|
description = "Models read-only para autenticação compartilhada entre projetos Django."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.13"
|
|
@@ -38,11 +38,27 @@ class OrganizationMixin(models.Model):
|
|
|
38
38
|
models.Index(fields=["organization_id"]),
|
|
39
39
|
]
|
|
40
40
|
|
|
41
|
+
@classmethod
|
|
42
|
+
def prefetch_organizations(cls, queryset, request, org_ids=None):
|
|
43
|
+
if not hasattr(request, "_orgs_dict"):
|
|
44
|
+
from shared_auth.utils import get_organization_model
|
|
45
|
+
|
|
46
|
+
Organization = get_organization_model()
|
|
47
|
+
if org_ids is None:
|
|
48
|
+
org_ids = list(
|
|
49
|
+
queryset.values_list("organization_id", flat=True).distinct()
|
|
50
|
+
)
|
|
51
|
+
if not org_ids:
|
|
52
|
+
request._orgs_dict = {}
|
|
53
|
+
return queryset
|
|
54
|
+
|
|
55
|
+
orgs_qs = Organization.objects.filter(pk__in=org_ids)
|
|
56
|
+
request._orgs_dict = {org.pk: org for org in orgs_qs}
|
|
57
|
+
|
|
58
|
+
return queryset
|
|
59
|
+
|
|
41
60
|
@property
|
|
42
61
|
def organization(self):
|
|
43
|
-
"""
|
|
44
|
-
Acessa organização do banco de auth (lazy loading com cache)
|
|
45
|
-
"""
|
|
46
62
|
if not hasattr(self, "_cached_organization"):
|
|
47
63
|
from shared_auth.utils import get_organization_model
|
|
48
64
|
|
|
@@ -251,6 +267,12 @@ class LoggedOrganizationMixin(viewsets.ModelViewSet):
|
|
|
251
267
|
serializer.save()
|
|
252
268
|
|
|
253
269
|
|
|
270
|
+
class PrefetchOrganizationsMixin(LoggedOrganizationMixin):
|
|
271
|
+
def get_queryset(self):
|
|
272
|
+
queryset = super().get_queryset()
|
|
273
|
+
return OrganizationMixin.prefetch_organizations(queryset, self.request)
|
|
274
|
+
|
|
275
|
+
|
|
254
276
|
class TimestampedMixin(models.Model):
|
|
255
277
|
"""
|
|
256
278
|
Mixin para adicionar timestamps
|
|
@@ -79,25 +79,27 @@ class OrganizationSerializerMixin(serializers.ModelSerializer):
|
|
|
79
79
|
organization = serializers.SerializerMethodField()
|
|
80
80
|
|
|
81
81
|
def get_organization(self, obj):
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return
|
|
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
|
+
if org:
|
|
85
|
+
return self._serialize_org(org)
|
|
86
|
+
return self._serialize_org(obj.organization)
|
|
87
|
+
|
|
88
|
+
def _serialize_org(self, org):
|
|
89
|
+
return {
|
|
90
|
+
"id": org.pk,
|
|
91
|
+
"name": org.name,
|
|
92
|
+
"fantasy_name": org.fantasy_name,
|
|
93
|
+
"image_organization": org.image_organization.url
|
|
94
|
+
if org.image_organization
|
|
95
|
+
else None,
|
|
96
|
+
"cnpj": org.cnpj,
|
|
97
|
+
"email": org.email,
|
|
98
|
+
"telephone": org.telephone,
|
|
99
|
+
"cellphone": org.cellphone,
|
|
100
|
+
"is_branch": org.is_branch,
|
|
101
|
+
"is_active": org.is_active(),
|
|
102
|
+
}
|
|
101
103
|
|
|
102
104
|
|
|
103
105
|
class OrganizationListCreateSerializerMixin(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/abstract_models.py
RENAMED
|
File without changes
|
|
File without changes
|
{maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/authentication.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
|
{maquinaweb_shared_auth-0.2.38 → maquinaweb_shared_auth-0.2.40}/shared_auth/storage_backend.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|