componentsDjangoType 2.0.16__tar.gz → 2.0.18__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.0.16/componentsDjangoType.egg-info → componentsdjangotype-2.0.18}/PKG-INFO +1 -1
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/componentsDjangoType/management/commands/createApp.py +2 -62
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18/componentsDjangoType.egg-info}/PKG-INFO +1 -1
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/componentsDjangoType.egg-info/SOURCES.txt +4 -1
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/services/authenticator_configurator.py +61 -23
- componentsdjangotype-2.0.18/services/home/__init__.py +0 -0
- componentsdjangotype-2.0.18/services/home/urls_page.py +10 -0
- componentsdjangotype-2.0.18/services/home/views_page.py +24 -0
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/setup.py +1 -1
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/LICENSE +0 -0
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/MANIFEST.in +0 -0
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/README.md +0 -0
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/componentsDjangoType/__init__.py +0 -0
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/componentsDjangoType/management/__init__.py +0 -0
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/componentsDjangoType/management/commands/__init__.py +0 -0
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/componentsDjangoType/management/commands/createcomponent.py +0 -0
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/componentsDjangoType.egg-info/dependency_links.txt +0 -0
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/componentsDjangoType.egg-info/requires.txt +0 -0
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/componentsDjangoType.egg-info/top_level.txt +0 -0
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/services/__init__.py +0 -0
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/services/authentication/__init__.py +0 -0
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/services/authentication/auth.py +0 -0
- {componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/setup.cfg +0 -0
@@ -36,69 +36,9 @@ class Command(BaseCommand):
|
|
36
36
|
# Paso 4: Crear la carpeta services y el archivo authentication.py en Home
|
37
37
|
creation.creation_auth(self.stdout)
|
38
38
|
|
39
|
-
|
39
|
+
# 5 creacion de las carpetas views y urls.py
|
40
|
+
creation.create_views_urls(self.stdout)
|
40
41
|
|
41
|
-
def modify_views_and_urls():
|
42
|
-
# Rutas de los archivos
|
43
|
-
views_path = os.path.join(home_dir, 'views.py')
|
44
|
-
urls_path = os.path.join(home_dir, 'urls.py')
|
45
|
-
|
46
|
-
# Contenido de views.py
|
47
|
-
views_content = """from django.shortcuts import render
|
48
|
-
from django.contrib.auth.decorators import login_required
|
49
|
-
from Home.services.authentication import Authentication
|
50
|
-
|
51
|
-
# Create your views here.
|
52
|
-
|
53
|
-
def home(request):
|
54
|
-
return render(request, 'home.html')
|
55
|
-
|
56
|
-
def signup(request):
|
57
|
-
return Authentication.get_signup(request)
|
58
|
-
|
59
|
-
def signout(request):
|
60
|
-
return Authentication.get_signout(request)
|
61
|
-
|
62
|
-
def signing(request):
|
63
|
-
return Authentication.get_signing(request)
|
64
|
-
|
65
|
-
@login_required
|
66
|
-
def logged(request):
|
67
|
-
return Authentication.get_logged(request)
|
68
|
-
|
69
|
-
def custom_dispatch(request, *args, **kwargs):
|
70
|
-
return Authentication.dispatch(request, *args, **kwargs)
|
71
|
-
"""
|
72
|
-
|
73
|
-
# Contenido de urls.py
|
74
|
-
urls_content = """from django.urls import path
|
75
|
-
from . import views
|
76
|
-
|
77
|
-
urlpatterns = [
|
78
|
-
path("", views.home, name='home'),
|
79
|
-
path("signup", views.signup, name='signup'),
|
80
|
-
path("login", views.signing, name='login'),
|
81
|
-
path("logout", views.signout, name='logout'),
|
82
|
-
path("logged", views.logged, name='logged'),
|
83
|
-
]
|
84
|
-
"""
|
85
|
-
# Escritura de views.py
|
86
|
-
try:
|
87
|
-
with open(views_path, 'w') as views_file:
|
88
|
-
views_file.write(views_content.strip())
|
89
|
-
print(f"Archivo modificado correctamente: {views_path}")
|
90
|
-
except Exception as e:
|
91
|
-
print(f"Error al modificar {views_path}: {e}")
|
92
|
-
|
93
|
-
# Escritura de urls.py
|
94
|
-
try:
|
95
|
-
with open(urls_path, 'w') as urls_file:
|
96
|
-
urls_file.write(urls_content.strip())
|
97
|
-
print(f"Archivo modificado correctamente: {urls_path}")
|
98
|
-
except Exception as e:
|
99
|
-
print(f"Error al modificar {urls_path}: {e}")
|
100
|
-
|
101
|
-
modify_views_and_urls()
|
102
42
|
|
103
43
|
# Paso 8: Crear la carpeta templates y estatic y los archivos HTML CSS y JS
|
104
44
|
templates_dir = os.path.join(app_name, 'templates')
|
@@ -15,4 +15,7 @@ componentsDjangoType/management/commands/createcomponent.py
|
|
15
15
|
services/__init__.py
|
16
16
|
services/authenticator_configurator.py
|
17
17
|
services/authentication/__init__.py
|
18
|
-
services/authentication/auth.py
|
18
|
+
services/authentication/auth.py
|
19
|
+
services/home/__init__.py
|
20
|
+
services/home/urls_page.py
|
21
|
+
services/home/views_page.py
|
{componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/services/authenticator_configurator.py
RENAMED
@@ -3,6 +3,7 @@ import ast
|
|
3
3
|
from django.core.management.base import BaseCommand
|
4
4
|
from django.core.management import call_command
|
5
5
|
from services.authentication import auth
|
6
|
+
from services.home import views_page, urls_page
|
6
7
|
|
7
8
|
class DjangoProjectManager:
|
8
9
|
def __init__(self, app_name, project_name):
|
@@ -47,7 +48,7 @@ class DjangoProjectManager:
|
|
47
48
|
# Comprobar si la aplicación no está ya en INSTALLED_APPS
|
48
49
|
if f"'{self.app_name}'" not in installed_apps_content:
|
49
50
|
# Insertar la aplicación dentro de la lista
|
50
|
-
new_installed_apps = installed_apps_content[:-1] + f"
|
51
|
+
new_installed_apps = installed_apps_content[:-1] + f" '{self.app_name}',\n]"
|
51
52
|
|
52
53
|
# Reemplazar el bloque INSTALLED_APPS con la nueva lista
|
53
54
|
new_settings_content = settings_content[:installed_apps_start] + new_installed_apps + settings_content[installed_apps_end:]
|
@@ -73,52 +74,48 @@ class DjangoProjectManager:
|
|
73
74
|
stdout.write(f"Creando el archivo '{project_urls_path}'...")
|
74
75
|
with open(project_urls_path, 'w') as f:
|
75
76
|
f.write("""from django.contrib import admin
|
76
|
-
from django.urls import path, include
|
77
|
+
from django.urls import path, include # Asegúrate de incluir include
|
78
|
+
|
77
79
|
urlpatterns = [
|
78
|
-
|
79
|
-
|
80
|
+
path('admin/', admin.site.urls),
|
81
|
+
path('', include('home.urls'))
|
80
82
|
# Añade tus rutas aquí
|
81
|
-
]
|
83
|
+
]
|
84
|
+
""")
|
82
85
|
else:
|
83
|
-
#
|
84
|
-
stdout.write(f"El archivo '{project_urls_path}' ya existe. Verificando contenido
|
85
|
-
|
86
|
+
# Leer el contenido actual del archivo
|
87
|
+
stdout.write(f"El archivo '{project_urls_path}' ya existe. Verificando contenido...\n")
|
86
88
|
with open(project_urls_path, 'r') as f:
|
87
89
|
urls_content = f.read()
|
88
90
|
|
89
91
|
updated = False
|
90
92
|
|
91
|
-
# Verificar si '
|
92
|
-
if 'urlpatterns = [' not in urls_content:
|
93
|
-
stdout.write(f"No se encontró 'urlpatterns'. Creando la lista de rutas desde cero.")
|
94
|
-
urls_content += "\nurlpatterns = [\n path('admin/', admin.site.urls),\n]\n"
|
95
|
-
updated = True
|
96
|
-
|
97
|
-
# Agregar 'include' si no está presente
|
93
|
+
# Verificar si 'include' está importado
|
98
94
|
if 'include' not in urls_content:
|
99
|
-
stdout.write("Agregando 'include' a los imports
|
95
|
+
stdout.write("Agregando 'include' a los imports.\n")
|
100
96
|
urls_content = urls_content.replace(
|
101
97
|
"from django.urls import path",
|
102
|
-
"from django.urls import path, include"
|
98
|
+
"from django.urls import path, include" # Asegura que 'include' se agregue
|
103
99
|
)
|
104
100
|
updated = True
|
105
101
|
|
106
|
-
#
|
102
|
+
# Verificar si la ruta de 'Home.urls' está en 'urlpatterns'
|
107
103
|
if "include('home.urls')" not in urls_content:
|
108
|
-
stdout.write("Agregando ruta para 'home.urls'
|
104
|
+
stdout.write("Agregando ruta para 'home.urls'.\n")
|
105
|
+
# Asegúrate de agregar la ruta en el lugar adecuado dentro de 'urlpatterns'
|
109
106
|
urls_content = urls_content.replace(
|
110
107
|
"urlpatterns = [",
|
111
|
-
"urlpatterns = [\n path('', include('home.urls'))
|
108
|
+
"urlpatterns = [\n path('', include('home.urls')), # Ruta para home\n"
|
112
109
|
)
|
113
110
|
updated = True
|
114
111
|
|
115
|
-
# Escribir
|
112
|
+
# Escribir los cambios si se modificó algo
|
116
113
|
if updated:
|
117
114
|
with open(project_urls_path, 'w') as f:
|
118
115
|
f.write(urls_content)
|
119
|
-
stdout.write(f"El archivo '{project_urls_path}' fue actualizado
|
116
|
+
stdout.write(f"El archivo '{project_urls_path}' fue actualizado.\n")
|
120
117
|
else:
|
121
|
-
stdout.write(f"No fue necesario realizar cambios en '{project_urls_path}'
|
118
|
+
stdout.write(f"No fue necesario realizar cambios en '{project_urls_path}'.\n")
|
122
119
|
|
123
120
|
def creation_auth(self, stdout):
|
124
121
|
services_dir = os.path.join(self.app_name, 'services')
|
@@ -153,7 +150,48 @@ urlpatterns = [
|
|
153
150
|
else:
|
154
151
|
stdout.write(f"El archivo '{authentication_path}' ya existe.")
|
155
152
|
|
153
|
+
def create_views_urls(self, stdout):
|
154
|
+
home_dir = 'Home'
|
155
|
+
views_path = os.path.join(home_dir, 'views.py')
|
156
|
+
urls_path = os.path.join(home_dir, 'urls.py')
|
157
|
+
|
158
|
+
# Crear el directorio si no existe
|
159
|
+
os.makedirs(home_dir, exist_ok=True)
|
160
|
+
|
161
|
+
# Obtener la ruta absoluta de los archivos fuente
|
162
|
+
views_source_path = os.path.abspath(views_page.__file__)
|
163
|
+
urls_source_path = os.path.abspath(urls_page.__file__)
|
164
|
+
|
165
|
+
# Comprobar si los archivos fuente existen
|
166
|
+
if not os.path.exists(views_source_path):
|
167
|
+
stdout.write(f"El archivo fuente '{views_source_path}' no existe. Verifica la instalación del paquete.\n")
|
168
|
+
creation = input("¿Quieres crear el archivo 'views.py'? (s/n): ")
|
169
|
+
if creation.lower() == 's':
|
170
|
+
self.create_file(views_source_path, views_path, stdout)
|
171
|
+
else:
|
172
|
+
return
|
173
|
+
|
174
|
+
if not os.path.exists(urls_source_path):
|
175
|
+
stdout.write(f"El archivo fuente '{urls_source_path}' no existe. Verifica la instalación del paquete.\n")
|
176
|
+
creation = input("¿Quieres crear el archivo 'urls.py'? (s/n): ")
|
177
|
+
if creation.lower() == 's':
|
178
|
+
self.create_file(urls_source_path, urls_path, stdout)
|
179
|
+
else:
|
180
|
+
return
|
181
|
+
|
182
|
+
def create_file(self, source_path, dest_path, stdout):
|
183
|
+
try:
|
184
|
+
# Leer el contenido del archivo fuente
|
185
|
+
with open(source_path, 'r') as source_file:
|
186
|
+
code = source_file.read()
|
187
|
+
|
188
|
+
# Crear y escribir el contenido en el archivo de destino
|
189
|
+
with open(dest_path, 'w') as dest_file:
|
190
|
+
dest_file.write(code)
|
156
191
|
|
192
|
+
stdout.write(f"El archivo '{dest_path}' fue creado y el código fue copiado.\n")
|
193
|
+
except Exception as e:
|
194
|
+
stdout.write(f"Error al copiar el archivo: {e}\n")
|
157
195
|
|
158
196
|
|
159
197
|
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
from django.urls import path
|
2
|
+
from . import views
|
3
|
+
|
4
|
+
urlpatterns = [
|
5
|
+
path("", views.home, name='home'),
|
6
|
+
path("signup", views.signup, name='signup'),
|
7
|
+
path("login", views.signing, name='login'),
|
8
|
+
path("logout", views.signout, name='logout'),
|
9
|
+
path("logged", views.logged, name='logged'),
|
10
|
+
]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
from django.shortcuts import render
|
2
|
+
from django.contrib.auth.decorators import login_required
|
3
|
+
from Home.services.authentication import Authentication
|
4
|
+
|
5
|
+
# Create your views here.
|
6
|
+
|
7
|
+
def home(request):
|
8
|
+
return render(request, 'home.html')
|
9
|
+
|
10
|
+
def signup(request):
|
11
|
+
return Authentication.get_signup(request)
|
12
|
+
|
13
|
+
def signout(request):
|
14
|
+
return Authentication.get_signout(request)
|
15
|
+
|
16
|
+
def signing(request):
|
17
|
+
return Authentication.get_signing(request)
|
18
|
+
|
19
|
+
@login_required
|
20
|
+
def logged(request):
|
21
|
+
return Authentication.get_logged(request)
|
22
|
+
|
23
|
+
def custom_dispatch(request, *args, **kwargs):
|
24
|
+
return Authentication.dispatch(request, *args, **kwargs)
|
File without changes
|
File without changes
|
File without changes
|
{componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/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
|
{componentsdjangotype-2.0.16 → componentsdjangotype-2.0.18}/services/authentication/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|