maquinaweb-shared-auth 0.2.35__py3-none-any.whl → 0.2.37__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.35.dist-info → maquinaweb_shared_auth-0.2.37.dist-info}/METADATA +1 -1
- {maquinaweb_shared_auth-0.2.35.dist-info → maquinaweb_shared_auth-0.2.37.dist-info}/RECORD +6 -6
- shared_auth/serializers.py +2 -2
- shared_auth/utils.py +32 -16
- {maquinaweb_shared_auth-0.2.35.dist-info → maquinaweb_shared_auth-0.2.37.dist-info}/WHEEL +0 -0
- {maquinaweb_shared_auth-0.2.35.dist-info → maquinaweb_shared_auth-0.2.37.dist-info}/top_level.txt +0 -0
|
@@ -12,12 +12,12 @@ shared_auth/mixins.py,sha256=kcTkjrNu-UGLwXQHsq9vQDx7qQjILa3Na8HvouLU3Ms,7588
|
|
|
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=GCypQOZJvsUHxxYOwrVt0PvV7ePPr3Dqed_BIymfULk,14255
|
|
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=u4XszJHXH_s7qk4_L5Q7hGBU5Vcl2tvUkwwQOEZLynY,3857
|
|
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.37.dist-info/METADATA,sha256=HQdf_Ptt9KnaNKspYCp-ljMCnf0MmMo5fkmz3nOzwB4,26325
|
|
21
|
+
maquinaweb_shared_auth-0.2.37.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
22
|
+
maquinaweb_shared_auth-0.2.37.dist-info/top_level.txt,sha256=msyYRy02ZV7zz7GR1raUI5LXGFIFn2TIkgkeKZqKufE,12
|
|
23
|
+
maquinaweb_shared_auth-0.2.37.dist-info/RECORD,,
|
shared_auth/serializers.py
CHANGED
|
@@ -13,7 +13,7 @@ Se quiser usar separadamente:
|
|
|
13
13
|
|
|
14
14
|
from rest_framework import serializers
|
|
15
15
|
|
|
16
|
-
from .utils import get_organization_model, get_user_model
|
|
16
|
+
from .utils import get_organization_model, get_organization_serializer, get_user_model
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class OrganizationCreateSerializerMixin(serializers.ModelSerializer):
|
|
@@ -117,7 +117,7 @@ class OrganizationListCreateSerializerMixin(
|
|
|
117
117
|
pass
|
|
118
118
|
|
|
119
119
|
|
|
120
|
-
class OrganizationSerializer(
|
|
120
|
+
class OrganizationSerializer(get_organization_serializer()):
|
|
121
121
|
"""
|
|
122
122
|
Serializer para o model de Organization configurado.
|
|
123
123
|
Usa get_organization_model() para suportar models customizados.
|
shared_auth/utils.py
CHANGED
|
@@ -4,7 +4,9 @@ Similar ao get_user_model() do Django
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
from django.apps import apps
|
|
7
|
+
from django.conf import importlib
|
|
7
8
|
from django.core.exceptions import ImproperlyConfigured
|
|
9
|
+
from rest_framework import serializers
|
|
8
10
|
|
|
9
11
|
from .conf import get_setting
|
|
10
12
|
|
|
@@ -12,15 +14,15 @@ from .conf import get_setting
|
|
|
12
14
|
def get_token_model():
|
|
13
15
|
"""
|
|
14
16
|
Retorna o model de Token configurado ou o padrão.
|
|
15
|
-
|
|
17
|
+
|
|
16
18
|
Usage:
|
|
17
19
|
from shared_auth.utils import get_token_model
|
|
18
|
-
|
|
20
|
+
|
|
19
21
|
Token = get_token_model()
|
|
20
22
|
token = Token.objects.get(key='abc123')
|
|
21
23
|
"""
|
|
22
|
-
model_string = get_setting(
|
|
23
|
-
|
|
24
|
+
model_string = get_setting("SHARED_AUTH_TOKEN_MODEL", "shared_auth.SharedToken")
|
|
25
|
+
|
|
24
26
|
try:
|
|
25
27
|
return apps.get_model(model_string, require_ready=False)
|
|
26
28
|
except ValueError:
|
|
@@ -38,15 +40,17 @@ def get_token_model():
|
|
|
38
40
|
def get_organization_model():
|
|
39
41
|
"""
|
|
40
42
|
Retorna o model de Organization configurado ou o padrão.
|
|
41
|
-
|
|
43
|
+
|
|
42
44
|
Usage:
|
|
43
45
|
from shared_auth.utils import get_organization_model
|
|
44
|
-
|
|
46
|
+
|
|
45
47
|
Organization = get_organization_model()
|
|
46
48
|
org = Organization.objects.get(id=1)
|
|
47
49
|
"""
|
|
48
|
-
model_string = get_setting(
|
|
49
|
-
|
|
50
|
+
model_string = get_setting(
|
|
51
|
+
"SHARED_AUTH_ORGANIZATION_MODEL", "shared_auth.SharedOrganization"
|
|
52
|
+
)
|
|
53
|
+
|
|
50
54
|
try:
|
|
51
55
|
return apps.get_model(model_string, require_ready=False)
|
|
52
56
|
except ValueError:
|
|
@@ -64,15 +68,15 @@ def get_organization_model():
|
|
|
64
68
|
def get_user_model():
|
|
65
69
|
"""
|
|
66
70
|
Retorna o model de User configurado ou o padrão.
|
|
67
|
-
|
|
71
|
+
|
|
68
72
|
Usage:
|
|
69
73
|
from shared_auth.utils import get_user_model
|
|
70
|
-
|
|
74
|
+
|
|
71
75
|
User = get_user_model()
|
|
72
76
|
user = User.objects.get(id=1)
|
|
73
77
|
"""
|
|
74
|
-
model_string = get_setting(
|
|
75
|
-
|
|
78
|
+
model_string = get_setting("SHARED_AUTH_USER_MODEL", "shared_auth.User")
|
|
79
|
+
|
|
76
80
|
try:
|
|
77
81
|
return apps.get_model(model_string, require_ready=False)
|
|
78
82
|
except ValueError:
|
|
@@ -90,15 +94,15 @@ def get_user_model():
|
|
|
90
94
|
def get_member_model():
|
|
91
95
|
"""
|
|
92
96
|
Retorna o model de Member configurado ou o padrão.
|
|
93
|
-
|
|
97
|
+
|
|
94
98
|
Usage:
|
|
95
99
|
from shared_auth.utils import get_member_model
|
|
96
|
-
|
|
100
|
+
|
|
97
101
|
Member = get_member_model()
|
|
98
102
|
member = Member.objects.get(id=1)
|
|
99
103
|
"""
|
|
100
|
-
model_string = get_setting(
|
|
101
|
-
|
|
104
|
+
model_string = get_setting("SHARED_AUTH_MEMBER_MODEL", "shared_auth.SharedMember")
|
|
105
|
+
|
|
102
106
|
try:
|
|
103
107
|
return apps.get_model(model_string, require_ready=False)
|
|
104
108
|
except ValueError:
|
|
@@ -111,3 +115,15 @@ def get_member_model():
|
|
|
111
115
|
f"SHARED_AUTH_MEMBER_MODEL refere-se ao model '{model_string}' "
|
|
112
116
|
f"que não foi instalado ou é inválido."
|
|
113
117
|
)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def get_organization_serializer():
|
|
121
|
+
model_string = get_setting("SHARED_AUTH_ORGANIZATION_SERIALIZER", None)
|
|
122
|
+
|
|
123
|
+
if not model_string:
|
|
124
|
+
return serializers.ModelSerializer
|
|
125
|
+
|
|
126
|
+
try:
|
|
127
|
+
return importlib.import_module(model_string)
|
|
128
|
+
except Exception:
|
|
129
|
+
return serializers.ModelSerializer
|
|
File without changes
|
{maquinaweb_shared_auth-0.2.35.dist-info → maquinaweb_shared_auth-0.2.37.dist-info}/top_level.txt
RENAMED
|
File without changes
|