componentsDjangoType 2.0.17__tar.gz → 2.0.19__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {componentsdjangotype-2.0.17/componentsDjangoType.egg-info → componentsdjangotype-2.0.19}/PKG-INFO +1 -1
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/componentsDjangoType/management/commands/createApp.py +2 -62
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19/componentsDjangoType.egg-info}/PKG-INFO +1 -1
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/componentsDjangoType.egg-info/SOURCES.txt +4 -1
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/services/authenticator_configurator.py +45 -15
- componentsdjangotype-2.0.19/services/home/__init__.py +0 -0
- componentsdjangotype-2.0.19/services/home/urls_page.py +10 -0
- componentsdjangotype-2.0.19/services/home/views_page.py +24 -0
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/setup.py +1 -1
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/LICENSE +0 -0
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/MANIFEST.in +0 -0
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/README.md +0 -0
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/componentsDjangoType/__init__.py +0 -0
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/componentsDjangoType/management/__init__.py +0 -0
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/componentsDjangoType/management/commands/__init__.py +0 -0
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/componentsDjangoType/management/commands/createcomponent.py +0 -0
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/componentsDjangoType.egg-info/dependency_links.txt +0 -0
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/componentsDjangoType.egg-info/requires.txt +0 -0
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/componentsDjangoType.egg-info/top_level.txt +0 -0
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/services/__init__.py +0 -0
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/services/authentication/__init__.py +0 -0
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/services/authentication/auth.py +0 -0
- {componentsdjangotype-2.0.17 → componentsdjangotype-2.0.19}/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.17 → componentsdjangotype-2.0.19}/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):
|
@@ -83,33 +84,28 @@ path('', include('home.urls'))
|
|
83
84
|
""")
|
84
85
|
else:
|
85
86
|
# Leer el contenido actual del archivo
|
86
|
-
stdout.write(f"El archivo '{project_urls_path}' ya existe. Verificando contenido
|
87
|
+
stdout.write(f"El archivo '{project_urls_path}' ya existe. Verificando contenido...\n")
|
87
88
|
with open(project_urls_path, 'r') as f:
|
88
89
|
urls_content = f.read()
|
89
90
|
|
90
91
|
updated = False
|
91
92
|
|
92
|
-
# Verificar
|
93
|
+
# Verificar si 'include' está importado
|
93
94
|
if 'include' not in urls_content:
|
94
|
-
stdout.write("Agregando 'include' a los imports
|
95
|
+
stdout.write("Agregando 'include' a los imports.\n")
|
95
96
|
urls_content = urls_content.replace(
|
96
97
|
"from django.urls import path",
|
97
|
-
"from django.urls import path, include"
|
98
|
+
"from django.urls import path, include" # Asegura que 'include' se agregue
|
98
99
|
)
|
99
100
|
updated = True
|
100
101
|
|
101
|
-
# Verificar
|
102
|
-
if 'urlpatterns = [' not in urls_content:
|
103
|
-
stdout.write("No se encontró 'urlpatterns'. Creando la lista de rutas desde cero.")
|
104
|
-
urls_content += "\nurlpatterns = [\n path('admin/', admin.site.urls),\n]\n"
|
105
|
-
updated = True
|
106
|
-
|
107
|
-
# Verificar o agregar la ruta para 'home.urls'
|
102
|
+
# Verificar si la ruta de 'Home.urls' está en 'urlpatterns'
|
108
103
|
if "include('home.urls')" not in urls_content:
|
109
|
-
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'
|
110
106
|
urls_content = urls_content.replace(
|
111
107
|
"urlpatterns = [",
|
112
|
-
"urlpatterns = [\n path('', include('home.urls'))
|
108
|
+
"urlpatterns = [\n path('', include('home.urls')), # Ruta para home\n"
|
113
109
|
)
|
114
110
|
updated = True
|
115
111
|
|
@@ -117,9 +113,9 @@ path('', include('home.urls'))
|
|
117
113
|
if updated:
|
118
114
|
with open(project_urls_path, 'w') as f:
|
119
115
|
f.write(urls_content)
|
120
|
-
stdout.write(f"El archivo '{project_urls_path}' fue actualizado
|
116
|
+
stdout.write(f"El archivo '{project_urls_path}' fue actualizado.\n")
|
121
117
|
else:
|
122
|
-
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")
|
123
119
|
|
124
120
|
def creation_auth(self, stdout):
|
125
121
|
services_dir = os.path.join(self.app_name, 'services')
|
@@ -154,7 +150,41 @@ path('', include('home.urls'))
|
|
154
150
|
else:
|
155
151
|
stdout.write(f"El archivo '{authentication_path}' ya existe.")
|
156
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
|
+
# Verificar y crear views.py
|
162
|
+
views_source_path = os.path.abspath(views_page.__file__) # Validar existencia
|
163
|
+
if not os.path.exists(views_source_path):
|
164
|
+
stdout.write(f"El archivo fuente '{views_source_path}' no existe.\n")
|
165
|
+
else:
|
166
|
+
self.create_file(views_source_path, views_path, stdout)
|
167
|
+
|
168
|
+
# Verificar y crear urls.py
|
169
|
+
urls_source_path = os.path.abspath(urls_page.__file__) # Validar existencia
|
170
|
+
if not os.path.exists(urls_source_path):
|
171
|
+
stdout.write(f"El archivo fuente '{urls_source_path}' no existe.\n")
|
172
|
+
else:
|
173
|
+
self.create_file(urls_source_path, urls_path, stdout)
|
174
|
+
|
175
|
+
def create_file(self, source_path, dest_path, stdout):
|
176
|
+
try:
|
177
|
+
# Leer el contenido del archivo fuente
|
178
|
+
with open(source_path, 'r') as source_file:
|
179
|
+
code = source_file.read()
|
180
|
+
|
181
|
+
# Crear y escribir el contenido en el archivo de destino
|
182
|
+
with open(dest_path, 'w') as dest_file:
|
183
|
+
dest_file.write(code)
|
157
184
|
|
185
|
+
stdout.write(f"El archivo '{dest_path}' fue creado y el código fue copiado.\n")
|
186
|
+
except Exception as e:
|
187
|
+
stdout.write(f"Error al copiar el archivo: {e}\n")
|
158
188
|
|
159
189
|
|
160
190
|
|
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.17 → componentsdjangotype-2.0.19}/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.17 → componentsdjangotype-2.0.19}/services/authentication/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|