componentsDjangoType 2.1.12__tar.gz → 2.1.15__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.
- {componentsdjangotype-2.1.12/componentsDjangoType.egg-info → componentsdjangotype-2.1.15}/PKG-INFO +1 -1
- componentsdjangotype-2.1.15/componentsDjangoType/management/commands/__pycache__/createApp.cpython-312.pyc +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/componentsDjangoType/management/commands/createApp.py +10 -5
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15/componentsDjangoType.egg-info}/PKG-INFO +1 -1
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/componentsDjangoType.egg-info/SOURCES.txt +3 -3
- componentsdjangotype-2.1.15/services/accounts/model.py +10 -0
- componentsdjangotype-2.1.15/services/authentication/auth.py +80 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/services/authenticator_configurator.py +129 -41
- componentsdjangotype-2.1.15/services/media/users/usuario.png +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/services/utils/views/layouts/index.html +2 -2
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/setup.py +3 -1
- componentsdjangotype-2.1.12/componentsDjangoType/management/commands/__pycache__/createApp.cpython-312.pyc +0 -0
- componentsdjangotype-2.1.12/services/authentication/auth.py +0 -76
- componentsdjangotype-2.1.12/services/utils/views/login.html +0 -33
- componentsdjangotype-2.1.12/services/utils/views/signup.html +0 -36
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/LICENSE +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/MANIFEST.in +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/README.md +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/componentsDjangoType/__init__.py +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/componentsDjangoType/__pycache__/__init__.cpython-312.pyc +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/componentsDjangoType/management/__init__.py +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/componentsDjangoType/management/__pycache__/__init__.cpython-312.pyc +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/componentsDjangoType/management/commands/__init__.py +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/componentsDjangoType/management/commands/__pycache__/__init__.cpython-312.pyc +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/componentsDjangoType/management/commands/createcomponent.py +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/componentsDjangoType.egg-info/dependency_links.txt +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/componentsDjangoType.egg-info/requires.txt +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/componentsDjangoType.egg-info/top_level.txt +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/services/__init__.py +0 -0
- {componentsdjangotype-2.1.12/services/authentication → componentsdjangotype-2.1.15/services/accounts}/__init__.py +0 -0
- {componentsdjangotype-2.1.12/services/utils → componentsdjangotype-2.1.15/services/authentication}/__init__.py +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/services/authentication/forms.py +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/services/copy_source.py +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/services/utils/css/authentication.css +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/services/utils/js/alertErrors.js +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/services/utils/views/home.html +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/services/utils/views/logged.html +0 -0
- {componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/setup.cfg +0 -0
Binary file
|
@@ -6,26 +6,31 @@ class Command(BaseCommand):
|
|
6
6
|
help = 'Crea una aplicación llamada Home, estructura de carpetas y configura urls automáticamente en el proyecto especificado'
|
7
7
|
|
8
8
|
def handle(self, *args, **kwargs):
|
9
|
-
# Nombre de la aplicación a crear
|
10
9
|
app_name = "Home"
|
11
|
-
|
10
|
+
app_accounts_name = "accounts"
|
11
|
+
|
12
12
|
# Paso 1: Solicitar el nombre de la aplicación principal al usuario
|
13
13
|
project_name = input(
|
14
14
|
"Por favor, ingresa el nombre de la aplicación principal del proyecto: ")
|
15
15
|
|
16
|
-
creation = DjangoProjectManager(app_name=app_name, project_name=project_name
|
16
|
+
creation = DjangoProjectManager(app_name=app_name, project_name=project_name,
|
17
|
+
app_accounts_name=app_accounts_name)
|
17
18
|
|
18
|
-
# Paso 2: Crear
|
19
|
-
creation.
|
19
|
+
# Paso 2: Crear las aplicaciónes "Home y accounts" si no existe
|
20
|
+
creation.create_apps()
|
20
21
|
|
21
22
|
# Agregar automáticamente 'Home' a INSTALLED_APPS
|
22
23
|
creation.installed_app()
|
24
|
+
|
25
|
+
creation.add_settings_modifications()
|
23
26
|
|
24
27
|
# Paso 3: Crear el archivo urls.py en la aplicación "Home" si no existe
|
25
28
|
creation.create_urls(self.stdout)
|
26
29
|
|
27
30
|
# Paso 4: Crear la carpeta services y el archivo authentication.py en Home
|
28
31
|
creation.creation_auth(self.stdout)
|
32
|
+
|
33
|
+
creation.create_profile_model()
|
29
34
|
|
30
35
|
# Paso 5: crea el urls.py y modifica el archivo views.py
|
31
36
|
creation.create_views_urls(self.stdout)
|
@@ -19,14 +19,14 @@ componentsDjangoType/management/commands/__pycache__/createApp.cpython-312.pyc
|
|
19
19
|
services/__init__.py
|
20
20
|
services/authenticator_configurator.py
|
21
21
|
services/copy_source.py
|
22
|
+
services/accounts/__init__.py
|
23
|
+
services/accounts/model.py
|
22
24
|
services/authentication/__init__.py
|
23
25
|
services/authentication/auth.py
|
24
26
|
services/authentication/forms.py
|
25
|
-
services/
|
27
|
+
services/media/users/usuario.png
|
26
28
|
services/utils/css/authentication.css
|
27
29
|
services/utils/js/alertErrors.js
|
28
30
|
services/utils/views/home.html
|
29
31
|
services/utils/views/logged.html
|
30
|
-
services/utils/views/login.html
|
31
|
-
services/utils/views/signup.html
|
32
32
|
services/utils/views/layouts/index.html
|
@@ -0,0 +1,10 @@
|
|
1
|
+
from django.db import models
|
2
|
+
from django.contrib.auth.models import AbstractUser
|
3
|
+
|
4
|
+
# Create your models here.
|
5
|
+
|
6
|
+
class Profile(AbstractUser):
|
7
|
+
image = models.ImageField(default='users/usuario.png', upload_to='users/')
|
8
|
+
|
9
|
+
class Meta:
|
10
|
+
app_label = 'accounts'
|
@@ -0,0 +1,80 @@
|
|
1
|
+
import logging
|
2
|
+
from django.shortcuts import render, redirect
|
3
|
+
from django.contrib.auth import login, logout, authenticate
|
4
|
+
from django.db import IntegrityError
|
5
|
+
from services.authentication.forms import customUserCreationform
|
6
|
+
from django.contrib.auth.decorators import login_required
|
7
|
+
|
8
|
+
logger = logging.getLogger(__name__)
|
9
|
+
|
10
|
+
class Authentication:
|
11
|
+
@staticmethod
|
12
|
+
def register(request):
|
13
|
+
if request.user.is_authenticated:
|
14
|
+
return redirect('logged')
|
15
|
+
|
16
|
+
if request.method == 'GET':
|
17
|
+
user_creation_form = customUserCreationform()
|
18
|
+
return render(request, 'registration/register.html', {'form': user_creation_form})
|
19
|
+
|
20
|
+
elif request.method == 'POST':
|
21
|
+
form = customUserCreationform(data=request.POST, files=request.FILES)
|
22
|
+
if form.is_valid():
|
23
|
+
try:
|
24
|
+
user = form.save()
|
25
|
+
user = authenticate(username=form.cleaned_data['username'],
|
26
|
+
password=form.cleaned_data['password1'])
|
27
|
+
if user is not None:
|
28
|
+
login(request, user)
|
29
|
+
return redirect('logged')
|
30
|
+
else:
|
31
|
+
return render(request, 'registration/register.html', {
|
32
|
+
'form': form,
|
33
|
+
'error': 'User could not be authenticated after registration.'
|
34
|
+
})
|
35
|
+
except IntegrityError:
|
36
|
+
logger.error("Integrity error during user registration", exc_info=True)
|
37
|
+
return render(request, 'registration/register.html', {
|
38
|
+
'form': form,
|
39
|
+
'error': 'Unable to register. Please try again later.'
|
40
|
+
})
|
41
|
+
except Exception as e:
|
42
|
+
logger.exception("Unexpected error during registration")
|
43
|
+
return render(request, 'registration/register.html', {
|
44
|
+
'form': form,
|
45
|
+
'error': f'An unexpected error occurred: {str(e)}'
|
46
|
+
})
|
47
|
+
else:
|
48
|
+
return render(request, 'registration/register.html', {
|
49
|
+
'form': form,
|
50
|
+
'error': 'Please correct the errors below.'
|
51
|
+
})
|
52
|
+
|
53
|
+
@staticmethod
|
54
|
+
def exit(request):
|
55
|
+
logout(request)
|
56
|
+
return redirect('home')
|
57
|
+
|
58
|
+
@staticmethod
|
59
|
+
@login_required
|
60
|
+
def logged(request):
|
61
|
+
return render(request, 'logged.html')
|
62
|
+
|
63
|
+
|
64
|
+
""" @staticmethod
|
65
|
+
def get_signing(request):
|
66
|
+
if request.method == 'GET':
|
67
|
+
return render(request, 'registerlogin.html', {
|
68
|
+
'form': AuthenticationForm()
|
69
|
+
})
|
70
|
+
elif request.method == 'POST':
|
71
|
+
form = AuthenticationForm(data=request.POST)
|
72
|
+
if form.is_valid():
|
73
|
+
user = form.get_user()
|
74
|
+
login(request, user)
|
75
|
+
return redirect('logged')
|
76
|
+
else:
|
77
|
+
return render(request, 'login.html', {
|
78
|
+
'form': form,
|
79
|
+
'error': 'Invalid username or password. Please try again.'
|
80
|
+
}) """
|
{componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/services/authenticator_configurator.py
RENAMED
@@ -1,18 +1,22 @@
|
|
1
1
|
import os
|
2
2
|
from django.core.management import call_command
|
3
3
|
from services.authentication import auth, forms
|
4
|
+
from services.accounts import model
|
4
5
|
from services.copy_source import copy_static_file
|
5
6
|
|
6
7
|
class DjangoProjectManager:
|
7
|
-
def __init__(self, app_name, project_name):
|
8
|
+
def __init__(self, app_name, project_name, app_accounts_name):
|
8
9
|
self.app_name = app_name
|
9
10
|
self.project_name = project_name
|
11
|
+
self.app_accounts = app_accounts_name
|
10
12
|
|
11
|
-
def
|
13
|
+
def create_apps(self):
|
12
14
|
"""
|
13
15
|
Crea una aplicación de Django con el nombre especificado si no existe.
|
14
16
|
"""
|
15
17
|
app_name = self.app_name
|
18
|
+
app_accounts = self.app_accounts
|
19
|
+
|
16
20
|
if not os.path.exists(app_name):
|
17
21
|
print(f"Creando la aplicación '{app_name}'...")
|
18
22
|
call_command('startapp', app_name)
|
@@ -22,20 +26,30 @@ class DjangoProjectManager:
|
|
22
26
|
print(f"Error: No se pudo crear la aplicación '{app_name}'.")
|
23
27
|
else:
|
24
28
|
print(f"La aplicación '{app_name}' ya existe.")
|
29
|
+
|
30
|
+
if not os.path.exists(app_accounts):
|
31
|
+
print(f"Creando la aplicación '{app_accounts}'...")
|
32
|
+
call_command('startapp', app_accounts)
|
33
|
+
if os.path.exists(app_accounts):
|
34
|
+
print(f"La aplicación '{app_accounts}' fue creada exitosamente.")
|
35
|
+
else:
|
36
|
+
print(f"Error: No se pudo crear la aplicación '{app_accounts}'.")
|
37
|
+
else:
|
38
|
+
print(f"La aplicación '{app_accounts}' ya existe.")
|
25
39
|
|
26
40
|
def installed_app(self):
|
27
41
|
"""
|
28
|
-
Agrega
|
29
|
-
si no
|
42
|
+
Agrega las aplicaciones al archivo settings.py en la lista INSTALLED_APPS
|
43
|
+
si no están ya presentes. Asegura que se mantenga el formato adecuado.
|
30
44
|
"""
|
31
45
|
settings_path = os.path.join(self.project_name, 'settings.py')
|
32
46
|
|
33
|
-
|
34
|
-
|
35
|
-
|
47
|
+
apps_to_add = [self.app_name, self.app_accounts]
|
48
|
+
|
49
|
+
try:
|
50
|
+
with open(settings_path, 'r') as file:
|
51
|
+
settings_content = file.read()
|
36
52
|
|
37
|
-
# Comprobar si la aplicación ya está en INSTALLED_APPS
|
38
|
-
if f"'{self.app_name}'" not in settings_content:
|
39
53
|
# Buscar la línea donde está la lista INSTALLED_APPS
|
40
54
|
installed_apps_start = settings_content.find("INSTALLED_APPS = [")
|
41
55
|
installed_apps_end = settings_content.find("]", installed_apps_start) + 1
|
@@ -43,23 +57,62 @@ class DjangoProjectManager:
|
|
43
57
|
# Extraer la lista INSTALLED_APPS
|
44
58
|
installed_apps_content = settings_content[installed_apps_start:installed_apps_end]
|
45
59
|
|
46
|
-
#
|
47
|
-
|
48
|
-
|
49
|
-
|
60
|
+
# Añadir cada aplicación si no está ya presente
|
61
|
+
for app in apps_to_add:
|
62
|
+
if f"'{app}'" not in installed_apps_content:
|
63
|
+
# Insertar la aplicación dentro de la lista
|
64
|
+
installed_apps_content = installed_apps_content[:-1] + f" '{app}',\n]"
|
50
65
|
|
51
|
-
|
52
|
-
|
66
|
+
# Reemplazar el bloque INSTALLED_APPS con la nueva lista
|
67
|
+
new_settings_content = settings_content[:installed_apps_start] + installed_apps_content + settings_content[installed_apps_end:]
|
53
68
|
|
54
|
-
|
55
|
-
|
56
|
-
|
69
|
+
# Escribir los cambios de vuelta en settings.py
|
70
|
+
with open(settings_path, 'w') as file:
|
71
|
+
file.write(new_settings_content)
|
57
72
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
print(f"
|
73
|
+
print(f"Las aplicaciones {', '.join(apps_to_add)} fueron agregadas a INSTALLED_APPS.")
|
74
|
+
except FileNotFoundError:
|
75
|
+
print(f"El archivo settings.py no se encontró en el proyecto '{self.project_name}'.")
|
76
|
+
except Exception as e:
|
77
|
+
print(f"Error al modificar INSTALLED_APPS: {e}")
|
78
|
+
|
79
|
+
def add_settings_modifications(self):
|
80
|
+
"""
|
81
|
+
Agrega la importación de 'os' y las variables de redirección
|
82
|
+
al archivo settings.py, si no están ya presentes.
|
83
|
+
"""
|
84
|
+
settings_path = os.path.join(self.project_name, 'settings.py')
|
85
|
+
|
86
|
+
# Leer el archivo settings.py
|
87
|
+
with open(settings_path, 'r') as file:
|
88
|
+
settings_content = file.readlines()
|
89
|
+
|
90
|
+
# Verificar si 'import os' ya está presente
|
91
|
+
if 'import os\n' not in settings_content:
|
92
|
+
settings_content.insert(12, 'import os\n') # Insertar al inicio del archivo
|
93
|
+
|
94
|
+
# Verificar si las variables de redirección ya están presentes
|
95
|
+
redirect_settings = [
|
96
|
+
'''\n# Variables globales\n
|
97
|
+
AUTH_USER_MODEL = 'accounts.Profile'
|
98
|
+
\n# Variables de redireccion
|
99
|
+
LOGIN_REDIRECT_URL = 'logged'
|
100
|
+
LOGOUT_REDIRECT_URL = 'home'
|
101
|
+
|
102
|
+
# Definiendo la carpeta media
|
103
|
+
MEDIA_URL = '/media/'
|
104
|
+
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
105
|
+
'''
|
106
|
+
]
|
107
|
+
for line in redirect_settings:
|
108
|
+
if line not in settings_content:
|
109
|
+
settings_content.append(line) # Agregar al final si no están
|
110
|
+
|
111
|
+
# Escribir los cambios de vuelta al archivo settings.py
|
112
|
+
with open(settings_path, 'w') as file:
|
113
|
+
file.writelines(settings_content)
|
114
|
+
|
115
|
+
print("Se han agregado 'import os' y las variables de redirección al archivo settings.py.")
|
63
116
|
|
64
117
|
def create_urls(self, stdout):
|
65
118
|
"""
|
@@ -73,10 +126,12 @@ class DjangoProjectManager:
|
|
73
126
|
with open(project_urls_path, 'w') as f:
|
74
127
|
f.write("""from django.contrib import admin
|
75
128
|
from django.urls import path, include # Asegúrate de incluir include
|
129
|
+
from django.conf import settings
|
76
130
|
|
77
131
|
urlpatterns = [
|
78
132
|
path('admin/', admin.site.urls),
|
79
|
-
path('', include('home.urls'))
|
133
|
+
path('', include('home.urls')),
|
134
|
+
path('accounts/', include('django.contrib.auth.urls')),
|
80
135
|
# Añade tus rutas aquí
|
81
136
|
]
|
82
137
|
""")
|
@@ -111,11 +166,17 @@ Including another URLconf
|
|
111
166
|
"""
|
112
167
|
from django.contrib import admin
|
113
168
|
from django.urls import path, include
|
169
|
+
from django.conf import settings
|
114
170
|
|
115
171
|
urlpatterns = [
|
116
172
|
path('admin/', admin.site.urls),
|
117
173
|
path('', include('Home.urls')),
|
174
|
+
path('accounts/', include('django.contrib.auth.urls')),
|
118
175
|
]
|
176
|
+
|
177
|
+
if settings.DEBUG:
|
178
|
+
from django.conf.urls.static import static
|
179
|
+
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
119
180
|
'''
|
120
181
|
updated = True
|
121
182
|
|
@@ -138,7 +199,7 @@ urlpatterns = [
|
|
138
199
|
|
139
200
|
# Usar el atributo __file__ del módulo 'auth' para obtener la ruta del archivo fuente
|
140
201
|
auth_source_path = os.path.abspath(auth.__file__)
|
141
|
-
forms_source_path = os.path.abspath(
|
202
|
+
forms_source_path = os.path.abspath(forms.__file__)
|
142
203
|
|
143
204
|
if not os.path.exists(auth_source_path):
|
144
205
|
stdout.write(f"El archivo fuente '{auth_source_path}' no existe. Verifica la instalación del paquete.")
|
@@ -170,6 +231,25 @@ urlpatterns = [
|
|
170
231
|
stdout.write(f"Error al copiar el archivo: {e}")
|
171
232
|
else:
|
172
233
|
stdout.write(f"El archivo '{authentication_path}' ya existe.")
|
234
|
+
|
235
|
+
def create_profile_model(self):
|
236
|
+
models_path = os.path.join(self.app_accounts, 'models.py')
|
237
|
+
|
238
|
+
model_source_path = os.path.abspath(model.__file__)
|
239
|
+
|
240
|
+
if not os.path.exists(model_source_path):
|
241
|
+
print(f"El archivo fuente '{model_source_path}' no existe. Verifica la instalación del paquete.")
|
242
|
+
return
|
243
|
+
|
244
|
+
try:
|
245
|
+
with open(model_source_path, 'r') as source_file:
|
246
|
+
model_code = source_file.read()
|
247
|
+
|
248
|
+
with open(models_path, 'w') as dest_file:
|
249
|
+
dest_file.write(model_code)
|
250
|
+
print(f"El archivo '{models_path}' fue creado y el código fue copiado.")
|
251
|
+
except Exception as e:
|
252
|
+
print(f"Error al crear o modificar el archivo '{models_path}': {e}")
|
173
253
|
|
174
254
|
def create_views_urls(self, stdout):
|
175
255
|
home_dir = 'Home' # Nombre de la aplicación Home
|
@@ -190,17 +270,14 @@ from services.authentication.auth import Authentication
|
|
190
270
|
def home(request):
|
191
271
|
return render(request, 'home.html')
|
192
272
|
|
193
|
-
def
|
194
|
-
return Authentication.
|
273
|
+
def register(request):
|
274
|
+
return Authentication.register(request)
|
195
275
|
|
196
|
-
def
|
197
|
-
return Authentication.
|
198
|
-
|
199
|
-
def signing(request):
|
200
|
-
return Authentication.get_signing(request)
|
276
|
+
def exit(request):
|
277
|
+
return Authentication.exit(request)
|
201
278
|
|
202
279
|
def logged(request):
|
203
|
-
return Authentication.
|
280
|
+
return Authentication.logged(request)
|
204
281
|
'''
|
205
282
|
with open(views_path, 'w') as views_file: # Abrir en modo escritura siempre
|
206
283
|
views_file.write(views_code)
|
@@ -213,9 +290,8 @@ from . import views
|
|
213
290
|
|
214
291
|
urlpatterns = [
|
215
292
|
path("", views.home, name='home'),
|
216
|
-
path("
|
217
|
-
path("
|
218
|
-
path("logout", views.signout, name='logout'),
|
293
|
+
path("register/", views.register, name='register'),
|
294
|
+
path("logout/", views.exit, name='exit'),
|
219
295
|
path("logged", views.logged, name='logged'),
|
220
296
|
]
|
221
297
|
'''
|
@@ -229,32 +305,44 @@ urlpatterns = [
|
|
229
305
|
def creation_utils(self, stdout):
|
230
306
|
|
231
307
|
app_name = self.app_name
|
308
|
+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
232
309
|
#creacion de los directorios
|
233
310
|
templates_dir = os.path.join(app_name, 'templates')
|
234
311
|
static_dir = os.path.join(app_name, 'static')
|
312
|
+
media_dir = os.path.join(BASE_DIR, 'media')
|
235
313
|
|
236
|
-
#
|
314
|
+
#creacion de subcarpetas
|
237
315
|
layouts_dir = os.path.join(templates_dir, 'layouts')
|
316
|
+
registration_dir = os.path.join(templates_dir, 'registration')
|
238
317
|
js_dir = os.path.join(static_dir, 'js')
|
239
318
|
css_dir = os.path.join(static_dir, 'css')
|
319
|
+
users_dir = os.path.join(media_dir, 'users')
|
240
320
|
|
241
321
|
# Crear las carpetas principales y subcarpetas
|
242
322
|
os.makedirs(templates_dir, exist_ok=True)
|
243
323
|
os.makedirs(layouts_dir, exist_ok=True)
|
324
|
+
os.makedirs(media_dir, exist_ok=True)
|
325
|
+
os.makedirs(registration_dir, exist_ok=True)
|
244
326
|
os.makedirs(static_dir, exist_ok=True)
|
245
327
|
os.makedirs(js_dir, exist_ok=True)
|
246
|
-
os.makedirs(css_dir, exist_ok=True)
|
328
|
+
os.makedirs(css_dir, exist_ok=True)
|
329
|
+
os.makedirs(users_dir, exist_ok=True)
|
247
330
|
|
248
331
|
stdout.write("Estructura de carpetas creada.\n")
|
249
332
|
|
250
333
|
files_to_copy = [
|
334
|
+
|
335
|
+
#carpetas principales
|
251
336
|
("services.utils.js", "alertErrors.js", os.path.join(js_dir, "alertErrors.js")),
|
252
337
|
("services.utils.css", "authentication.css", os.path.join(css_dir, "authentication.css")),
|
253
|
-
("services.utils.views.layouts", "index.html", os.path.join(layouts_dir, "index.html")),
|
254
338
|
("services.utils.views", "home.html", os.path.join(templates_dir, "home.html")),
|
255
|
-
("services.utils.views", "signup.html", os.path.join(templates_dir, "signup.html")),
|
256
|
-
("services.utils.views", "login.html", os.path.join(templates_dir, "login.html")),
|
257
339
|
("services.utils.views", "logged.html", os.path.join(templates_dir, "logged.html")),
|
340
|
+
|
341
|
+
#sub carpetas
|
342
|
+
("services.utils.views.layouts", "index.html", os.path.join(layouts_dir, "index.html")),
|
343
|
+
("services.utils.views.registration", "login.html", os.path.join(registration_dir, "login.html")),
|
344
|
+
("services.utils.views.registration", "register.html", os.path.join(registration_dir, "register.html")),
|
345
|
+
("services.media.users", "usuario.png", os.path.join(users_dir, "usuario.png")),
|
258
346
|
]
|
259
347
|
|
260
348
|
for package, resource_name, destination_path in files_to_copy:
|
Binary file
|
{componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/services/utils/views/layouts/index.html
RENAMED
@@ -21,9 +21,9 @@
|
|
21
21
|
</div>
|
22
22
|
<ul class="nav-links">
|
23
23
|
{% if user.is_authenticated %}
|
24
|
-
<li><a href="{% url '
|
24
|
+
<li><a href="{% url 'exit' %}" class="nav-item">Logout</a></li>
|
25
25
|
{% else %}
|
26
|
-
<li><a href="{% url '
|
26
|
+
<li><a href="{% url 'register' %}" class="nav-item">Sign Up</a></li>
|
27
27
|
<li><a href="{% url 'login' %}" class="nav-item">Login</a></li>
|
28
28
|
{% endif %}
|
29
29
|
</ul>
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name='componentsDjangoType',
|
5
|
-
version='2.1.
|
5
|
+
version='2.1.15',
|
6
6
|
packages=find_packages(),
|
7
7
|
include_package_data=True,
|
8
8
|
package_data={
|
@@ -11,6 +11,8 @@ setup(
|
|
11
11
|
'utils/css/*.css',
|
12
12
|
'utils/views/*.html',
|
13
13
|
'utils/views/layouts/*.html',
|
14
|
+
'media/users/*.jpg',
|
15
|
+
'media/users/*.png',
|
14
16
|
],
|
15
17
|
},
|
16
18
|
license='MIT',
|
Binary file
|
@@ -1,76 +0,0 @@
|
|
1
|
-
from django.shortcuts import render, redirect
|
2
|
-
from django.contrib.auth.forms import AuthenticationForm
|
3
|
-
from django.contrib.auth import login, logout
|
4
|
-
from django.db import IntegrityError
|
5
|
-
from services.authentication.forms import customUserCreationform
|
6
|
-
|
7
|
-
class Authentication:
|
8
|
-
@staticmethod
|
9
|
-
def get_signup(request):
|
10
|
-
if request.method == 'GET':
|
11
|
-
# Crear una nueva instancia del formulario en GET
|
12
|
-
return render(request, 'signup.html', {
|
13
|
-
'form': customUserCreationform() # Instancia del formulario
|
14
|
-
})
|
15
|
-
elif request.method == 'POST':
|
16
|
-
# Crear una instancia del formulario con los datos enviados
|
17
|
-
form = customUserCreationform(request.POST)
|
18
|
-
if form.is_valid():
|
19
|
-
try:
|
20
|
-
user = form.save()
|
21
|
-
login(request, user)
|
22
|
-
return redirect('logged')
|
23
|
-
except IntegrityError:
|
24
|
-
# Si ocurre un error de integridad (por ejemplo, nombre de usuario duplicado)
|
25
|
-
return render(request, 'signup.html', {
|
26
|
-
'form': form,
|
27
|
-
'error': 'Unable to register. Please try again later.'
|
28
|
-
})
|
29
|
-
else:
|
30
|
-
# Si el formulario no es válido, muestra los errores
|
31
|
-
return render(request, 'signup.html', {
|
32
|
-
'form': form,
|
33
|
-
'error': 'Please correct the errors below.'
|
34
|
-
})
|
35
|
-
|
36
|
-
@staticmethod
|
37
|
-
def get_signout(request):
|
38
|
-
logout(request)
|
39
|
-
return redirect('home')
|
40
|
-
|
41
|
-
@staticmethod
|
42
|
-
def get_signing(request):
|
43
|
-
if request.method == 'GET':
|
44
|
-
return render(request, 'login.html', {
|
45
|
-
'form': AuthenticationForm()
|
46
|
-
})
|
47
|
-
elif request.method == 'POST':
|
48
|
-
form = AuthenticationForm(data=request.POST)
|
49
|
-
if form.is_valid():
|
50
|
-
user = form.get_user()
|
51
|
-
login(request, user)
|
52
|
-
return redirect('logged')
|
53
|
-
else:
|
54
|
-
return render(request, 'login.html', {
|
55
|
-
'form': form,
|
56
|
-
'error': 'Invalid username or password. Please try again.'
|
57
|
-
})
|
58
|
-
|
59
|
-
@staticmethod
|
60
|
-
def get_logged(request):
|
61
|
-
return render(request, 'logged.html')
|
62
|
-
|
63
|
-
def dispatch(self, request, *args, **kwargs):
|
64
|
-
match request.path:
|
65
|
-
case "/signup":
|
66
|
-
return self.get_signup(request)
|
67
|
-
case "/login":
|
68
|
-
return self.get_signing(request)
|
69
|
-
case "/logout":
|
70
|
-
return self.get_signout(request)
|
71
|
-
case "/logged":
|
72
|
-
return self.get_logged(request)
|
73
|
-
case "/":
|
74
|
-
return self.get(request)
|
75
|
-
case _:
|
76
|
-
return self.get(request)
|
@@ -1,33 +0,0 @@
|
|
1
|
-
{% extends "layouts/index.html" %}
|
2
|
-
{% block layout %}
|
3
|
-
{% if error %}
|
4
|
-
<div class="alert" id="alert">
|
5
|
-
<div class="alert-content">
|
6
|
-
{{ error }}
|
7
|
-
<button class="close-btn" onclick="closeAlert()">
|
8
|
-
<span class="sr-only">Close</span>
|
9
|
-
<svg class="close-icon" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
10
|
-
<path d="M0.92524 0.687069C1.126 0.486219 1.39823 0.373377 1.68209 0.373377C1.96597 0.373377 2.2382 0.486219 2.43894 0.687069L8.10514 6.35813L13.7714 0.687069C13.8701 0.584748 13.9882 0.503105 14.1188 0.446962C14.2494 0.39082 14.3899 0.361248 14.5321 0.360026C14.6742 0.358783 14.8151 0.38589 14.9468 0.439762C15.0782 0.493633 15.1977 0.573197 15.2983 0.673783C15.3987 0.774389 15.4784 0.894026 15.5321 1.02568C15.5859 1.15736 15.6131 1.29845 15.6118 1.44071C15.6105 1.58297 15.5809 1.72357 15.5248 1.85428C15.4688 1.98499 15.3872 2.10324 15.2851 2.20206L9.61883 7.87312L15.2851 13.5441C15.4801 13.7462 15.588 14.0168 15.5854 14.2977C15.5831 14.5787 15.4705 14.8474 15.272 15.046C15.0735 15.2449 14.805 15.3574 14.5244 15.3599C14.2437 15.3623 13.9733 15.2543 13.7714 15.0591L8.10514 9.38812L2.43894 15.0591C2.23704 15.2543 1.96663 15.3623 1.68594 15.3599C1.40526 15.3574 1.13677 15.2449 0.938279 15.046C0.739807 14.8474 0.627232 14.5787 0.624791 14.2977C0.62235 14.0168 0.730236 13.7462 0.92524 13.5441L6.59144 7.87312L0.92524 2.20206C0.724562 2.00115 0.611816 1.72867 0.611816 1.44457C0.611816 1.16047 0.724562 0.887983 0.92524 0.687069Z" fill="currentColor"/>
|
11
|
-
</svg>
|
12
|
-
</button>
|
13
|
-
</div>
|
14
|
-
</div>
|
15
|
-
{% endif %}
|
16
|
-
|
17
|
-
<div class="form-wrapper">
|
18
|
-
<div class="form-container">
|
19
|
-
<form action="" method="post" class="form-control">
|
20
|
-
{% csrf_token %}
|
21
|
-
<h1>Login</h1>
|
22
|
-
|
23
|
-
<label for="username">Usuario:</label>
|
24
|
-
{{ form.username }}
|
25
|
-
|
26
|
-
<label for="password">Contraseña:</label>
|
27
|
-
<input type="password" id="password" name="password" value="{{ form.password2 }}" required>
|
28
|
-
|
29
|
-
<button type="submit">Login</button>
|
30
|
-
</form>
|
31
|
-
</div>
|
32
|
-
</div>
|
33
|
-
{% endblock %}
|
@@ -1,36 +0,0 @@
|
|
1
|
-
{% extends "layouts/index.html" %}
|
2
|
-
{% block layout %}
|
3
|
-
{% if error %}
|
4
|
-
<div class="alert" id="alert">
|
5
|
-
<div class="alert-content">
|
6
|
-
{{ error }}
|
7
|
-
<button class="close-btn" onclick="closeAlert()">
|
8
|
-
<span class="sr-only">Close</span>
|
9
|
-
<svg class="close-icon" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
10
|
-
<path d="M0.92524 0.687069C1.126 0.486219 1.39823 0.373377 1.68209 0.373377C1.96597 0.373377 2.2382 0.486219 2.43894 0.687069L8.10514 6.35813L13.7714 0.687069C13.8701 0.584748 13.9882 0.503105 14.1188 0.446962C14.2494 0.39082 14.3899 0.361248 14.5321 0.360026C14.6742 0.358783 14.8151 0.38589 14.9468 0.439762C15.0782 0.493633 15.1977 0.573197 15.2983 0.673783C15.3987 0.774389 15.4784 0.894026 15.5321 1.02568C15.5859 1.15736 15.6131 1.29845 15.6118 1.44071C15.6105 1.58297 15.5809 1.72357 15.5248 1.85428C15.4688 1.98499 15.3872 2.10324 15.2851 2.20206L9.61883 7.87312L15.2851 13.5441C15.4801 13.7462 15.588 14.0168 15.5854 14.2977C15.5831 14.5787 15.4705 14.8474 15.272 15.046C15.0735 15.2449 14.805 15.3574 14.5244 15.3599C14.2437 15.3623 13.9733 15.2543 13.7714 15.0591L8.10514 9.38812L2.43894 15.0591C2.23704 15.2543 1.96663 15.3623 1.68594 15.3599C1.40526 15.3574 1.13677 15.2449 0.938279 15.046C0.739807 14.8474 0.627232 14.5787 0.624791 14.2977C0.62235 14.0168 0.730236 13.7462 0.92524 13.5441L6.59144 7.87312L0.92524 2.20206C0.724562 2.00115 0.611816 1.72867 0.611816 1.44457C0.611816 1.16047 0.724562 0.887983 0.92524 0.687069Z" fill="currentColor"/>
|
11
|
-
</svg>
|
12
|
-
</button>
|
13
|
-
</div>
|
14
|
-
</div>
|
15
|
-
{% endif %}
|
16
|
-
|
17
|
-
<div class="form-wrapper">
|
18
|
-
<div class="form-container">
|
19
|
-
<form action="" method="post" class="form-control">
|
20
|
-
{% csrf_token %}
|
21
|
-
<h1>sing up</h1>
|
22
|
-
|
23
|
-
<label for="username">Usuario:</label>
|
24
|
-
{{ form.username }}
|
25
|
-
|
26
|
-
<label for="password1">Contraseña:</label>
|
27
|
-
{{ form.password1 }}
|
28
|
-
|
29
|
-
<label for="password2">Confirmar Contraseña:</label>
|
30
|
-
{{ form.password2 }}
|
31
|
-
|
32
|
-
<button type="submit">sing Up</button>
|
33
|
-
</form>
|
34
|
-
</div>
|
35
|
-
</div>
|
36
|
-
{% endblock %}
|
File without changes
|
File without changes
|
File without changes
|
{componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/componentsDjangoType/__init__.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
|
File without changes
|
File without changes
|
File without changes
|
{componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/services/authentication/forms.py
RENAMED
File without changes
|
File without changes
|
{componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/services/utils/css/authentication.css
RENAMED
File without changes
|
{componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/services/utils/js/alertErrors.js
RENAMED
File without changes
|
File without changes
|
{componentsdjangotype-2.1.12 → componentsdjangotype-2.1.15}/services/utils/views/logged.html
RENAMED
File without changes
|
File without changes
|