epok-toolkit 1.10.0__py3-none-any.whl → 1.11.1__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 epok-toolkit might be problematic. Click here for more details.
- epok_toolkit/django/utils/__init__.py +1 -0
- epok_toolkit/django/utils/magic_link.py +27 -0
- epok_toolkit/django/viewsets.py +18 -18
- {epok_toolkit-1.10.0.dist-info → epok_toolkit-1.11.1.dist-info}/METADATA +2 -1
- {epok_toolkit-1.10.0.dist-info → epok_toolkit-1.11.1.dist-info}/RECORD +8 -6
- {epok_toolkit-1.10.0.dist-info → epok_toolkit-1.11.1.dist-info}/WHEEL +0 -0
- {epok_toolkit-1.10.0.dist-info → epok_toolkit-1.11.1.dist-info}/licenses/LICENSE +0 -0
- {epok_toolkit-1.10.0.dist-info → epok_toolkit-1.11.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .magic_link import *
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from datetime import timedelta
|
|
2
|
+
import jwt
|
|
3
|
+
from django.utils import timezone
|
|
4
|
+
from django.conf import settings
|
|
5
|
+
|
|
6
|
+
def generate_login_magic_token(user, minutes_valid=10):
|
|
7
|
+
"""
|
|
8
|
+
Genera un token JWT válido por X minutos para login sin contraseña.
|
|
9
|
+
Incluye un propósito específico para distinguirlo de otros tipos de token.
|
|
10
|
+
"""
|
|
11
|
+
payload = {
|
|
12
|
+
"user_id": str(user.id),
|
|
13
|
+
"exp": timezone.now() + timedelta(minutes=minutes_valid),
|
|
14
|
+
"purpose": "magic_login",
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
token = jwt.encode(payload, settings.SECRET_KEY, algorithm="HS256")
|
|
18
|
+
if isinstance(token, bytes):
|
|
19
|
+
token = token.decode("utf-8")
|
|
20
|
+
return token
|
|
21
|
+
|
|
22
|
+
def build_login_magic_link(token):
|
|
23
|
+
"""
|
|
24
|
+
Construye el enlace completo hacia tu frontend.
|
|
25
|
+
Ajusta la ruta a donde quieras que el frontend reciba el token.
|
|
26
|
+
"""
|
|
27
|
+
return f"{settings.FRONTEND_URL}#/magic-login?token={token}"
|
epok_toolkit/django/viewsets.py
CHANGED
|
@@ -18,24 +18,24 @@ class BaseOptimizedViewSet(viewsets.ModelViewSet):
|
|
|
18
18
|
simple_serializer_class = None
|
|
19
19
|
full_serializer_class = None
|
|
20
20
|
|
|
21
|
-
def get_queryset(self):
|
|
22
|
-
|
|
21
|
+
# def get_queryset(self):
|
|
22
|
+
# qs = super().get_queryset()
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
# if not (hasattr(qs, 'full') and hasattr(qs, 'simple')):
|
|
25
|
+
# raise NotImplementedError(
|
|
26
|
+
# f"❌ El modelo {qs.model.__name__} no está usando un OptimizedManager con full() y simple()."
|
|
27
|
+
# )
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
# if self.action == 'list':
|
|
30
|
+
# return qs.simple()
|
|
31
|
+
# elif self.action in ['retrieve', 'update', 'partial_update']:
|
|
32
|
+
# return qs.full()
|
|
33
|
+
# return qs
|
|
34
34
|
|
|
35
|
-
def get_serializer_class(self):
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
# def get_serializer_class(self):
|
|
36
|
+
# # Cambia el serializer según la acción
|
|
37
|
+
# if self.action == 'list' and self.simple_serializer_class:
|
|
38
|
+
# return self.simple_serializer_class
|
|
39
|
+
# if self.action in ['retrieve', 'update', 'partial_update'] and self.full_serializer_class:
|
|
40
|
+
# return self.full_serializer_class
|
|
41
|
+
# return super().get_serializer_class()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: epok-toolkit
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.11.1
|
|
4
4
|
Summary: Una herramienta para la gestión de tareas y procesos en Django con Celery.
|
|
5
5
|
Author-email: Fernando Leon Franco <fernanlee2131@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -16,6 +16,7 @@ Requires-Dist: djangorestframework>=3.16.0
|
|
|
16
16
|
Requires-Dist: celery[redis]>=5.5.3
|
|
17
17
|
Requires-Dist: django-celery-beat>=2.6.0
|
|
18
18
|
Requires-Dist: colorstreak>=0.1.0
|
|
19
|
+
Requires-Dist: PyJWT>=2.10.1
|
|
19
20
|
Dynamic: license-file
|
|
20
21
|
|
|
21
22
|
# EPOK Toolkit
|
|
@@ -6,7 +6,9 @@ epok_toolkit/django/cache.py,sha256=R179_Hrlw1k0tsry9EN0zGl4-Of02L-VzE-xqFuXjaU,
|
|
|
6
6
|
epok_toolkit/django/fields.py,sha256=-ajP5qx-4bt9Qz9yW48gTlinTxD1xWPKOEkslqx8cSM,1089
|
|
7
7
|
epok_toolkit/django/manager.py,sha256=3MZcA9wQY4E1KD8XlgZQbzf4wlF9vA8Pntl_gKDWfpA,1350
|
|
8
8
|
epok_toolkit/django/response.py,sha256=O8OHBaKgUQjBeYLLbgTTs669l_4D6swUgAOwswjc-88,1716
|
|
9
|
-
epok_toolkit/django/viewsets.py,sha256=
|
|
9
|
+
epok_toolkit/django/viewsets.py,sha256=6OkQc7WgUQA-OlXPzm65w59vZOjlzQ0vuAorDwd8B5Q,1466
|
|
10
|
+
epok_toolkit/django/utils/__init__.py,sha256=zDuoqm_eksZQpL-Bvd_q2KGMtSXfprBjf4TScZiwV6k,25
|
|
11
|
+
epok_toolkit/django/utils/magic_link.py,sha256=GiDuy0kAGdYohGPlBL7rwpKPMpXuB1wJa1k5LTAOm4w,889
|
|
10
12
|
epok_toolkit/email/__init__.py,sha256=pyJwysyVoq6DuYAG72fulsKFoOuAfjw3aBH7FhmYGHc,35
|
|
11
13
|
epok_toolkit/email/email_async.py,sha256=oC0WowWNUpTpXdxo6hJag5gWUaStxI6VBEArEKQxXko,1521
|
|
12
14
|
epok_toolkit/email/engine.py,sha256=IIifqRI9z76pHdrO5oSSZ25aP5txOTAgrj1JuVVPlMY,2387
|
|
@@ -22,8 +24,8 @@ epok_toolkit/pdf/fuentes/Kollektif-Italic.ttf,sha256=1CXPyw43il9u0tQ_7aRzsEaVtg3
|
|
|
22
24
|
epok_toolkit/pdf/fuentes/Kollektif.ttf,sha256=7wTLkVVNUm1giLjIZcWRUH5r2r3o0GjdKic4V1A-pNQ,51128
|
|
23
25
|
epok_toolkit/pdf/plantillas/Ticket_congrats.png,sha256=OSQhVR0j_nLHE6kSJ33BTR-77HM1fNAfJBe2EuX6wVk,157141
|
|
24
26
|
epok_toolkit/pdf/plantillas/Ticket_congrats2.png,sha256=1RBogBdo-8WSMpD3H73HoLgJtr5EC5oVKfOCIWOxPSo,373605
|
|
25
|
-
epok_toolkit-1.
|
|
26
|
-
epok_toolkit-1.
|
|
27
|
-
epok_toolkit-1.
|
|
28
|
-
epok_toolkit-1.
|
|
29
|
-
epok_toolkit-1.
|
|
27
|
+
epok_toolkit-1.11.1.dist-info/licenses/LICENSE,sha256=iLDbGXdLSIOT5OsxzHCvtmxHtonE21GiFlS3LNkug4A,128
|
|
28
|
+
epok_toolkit-1.11.1.dist-info/METADATA,sha256=UAJxsK-UvYi4xFUP4k1gQPNlK-iW3NszfIJHcef_J80,768
|
|
29
|
+
epok_toolkit-1.11.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
30
|
+
epok_toolkit-1.11.1.dist-info/top_level.txt,sha256=Wo72AqIFcfWwBGM5F5iGFw9PrO3WBnTSprFZIJk_pNg,13
|
|
31
|
+
epok_toolkit-1.11.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|