componentsDjangoType 2.0.31__tar.gz → 2.0.33__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.
Files changed (29) hide show
  1. {componentsdjangotype-2.0.31/componentsDjangoType.egg-info → componentsdjangotype-2.0.33}/PKG-INFO +1 -1
  2. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/componentsDjangoType/management/commands/createApp.py +5 -237
  3. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33/componentsDjangoType.egg-info}/PKG-INFO +1 -1
  4. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/componentsDjangoType.egg-info/SOURCES.txt +6 -1
  5. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/services/authentication/auth.py +27 -30
  6. componentsdjangotype-2.0.33/services/authentication/forms.py +15 -0
  7. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/services/authenticator_configurator.py +56 -41
  8. componentsdjangotype-2.0.33/services/copy_source.py +32 -0
  9. componentsdjangotype-2.0.33/services/utils/__init__.py +0 -0
  10. componentsdjangotype-2.0.33/services/utils/css/__init__.py +0 -0
  11. componentsdjangotype-2.0.33/services/utils/js/__init__.py +0 -0
  12. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/setup.py +1 -1
  13. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/LICENSE +0 -0
  14. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/MANIFEST.in +0 -0
  15. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/README.md +0 -0
  16. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/componentsDjangoType/__init__.py +0 -0
  17. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/componentsDjangoType/__pycache__/__init__.cpython-312.pyc +0 -0
  18. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/componentsDjangoType/management/__init__.py +0 -0
  19. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/componentsDjangoType/management/__pycache__/__init__.cpython-312.pyc +0 -0
  20. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/componentsDjangoType/management/commands/__init__.py +0 -0
  21. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/componentsDjangoType/management/commands/__pycache__/__init__.cpython-312.pyc +0 -0
  22. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/componentsDjangoType/management/commands/__pycache__/createApp.cpython-312.pyc +0 -0
  23. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/componentsDjangoType/management/commands/createcomponent.py +0 -0
  24. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/componentsDjangoType.egg-info/dependency_links.txt +0 -0
  25. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/componentsDjangoType.egg-info/requires.txt +0 -0
  26. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/componentsDjangoType.egg-info/top_level.txt +0 -0
  27. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/services/__init__.py +0 -0
  28. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/services/authentication/__init__.py +0 -0
  29. {componentsdjangotype-2.0.31 → componentsdjangotype-2.0.33}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: componentsDjangoType
3
- Version: 2.0.31
3
+ Version: 2.0.33
4
4
  Summary: Comandos para crear archivos html, css y js
5
5
  Home-page: https://github.com/jose-CR/componentsDjangoType
6
6
  Author: Alejandro
@@ -36,29 +36,22 @@ 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
- creation.create_views_urls(self. stdout)
39
+ # Paso 5: crea el urls.py y modifica el archivo views.py
40
+ creation.create_views_urls(self.stdout)
40
41
 
41
- # Paso 8: Crear la carpeta templates y estatic y los archivos HTML CSS y JS
42
+ # Paso 6: Crear la carpeta templates y estatic y los archivos HTML CSS y JS
42
43
  templates_dir = os.path.join(app_name, 'templates')
43
- static_dir = os.path.join(app_name, 'static')
44
44
 
45
45
  # creacion de sub carpetas
46
46
  layouts_dir = os.path.join(templates_dir, 'layouts')
47
- js_dir = os.path.join(static_dir, 'js')
48
- css_dir = os.path.join(static_dir, 'css')
49
47
 
50
48
  # Crear las carpetas principales y subcarpetas
51
49
  os.makedirs(templates_dir, exist_ok=True)
52
- os.makedirs(static_dir, exist_ok=True)
53
50
  os.makedirs(layouts_dir, exist_ok=True)
54
- os.makedirs(js_dir, exist_ok=True)
55
- os.makedirs(css_dir, exist_ok=True)
56
51
 
57
- # creacion de los archivos
58
-
59
- js_file_path = os.path.join(js_dir, 'alertErrors.js')
52
+ creation.creation_utils(self.stdout)
60
53
 
61
- css_file_path = os.path.join(css_dir, 'authentication.css')
54
+ # creacion de los archivos
62
55
 
63
56
  layout_files_path = os.path.join(layouts_dir, 'index.html')
64
57
 
@@ -148,231 +141,6 @@ class Command(BaseCommand):
148
141
  write_file(template_file_path, content)
149
142
 
150
143
  # escritura de los archivos
151
-
152
- # escritura del archivos js
153
- write_file(js_file_path, """function closeAlert() {
154
- const alert = document.getElementById('alert');
155
- if (alert) {
156
- alert.remove();
157
- }
158
- }
159
- """)
160
-
161
- # escritura del archivo css
162
- write_file(css_file_path, """
163
- /* Navbar */
164
- .navbar {
165
- display: flex;
166
- justify-content: space-between;
167
- align-items: center;
168
- padding: 10px 20px;
169
- background-color: #333; /* Color de fondo */
170
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
171
- }
172
-
173
- /* Logo */
174
- .navbar .logo a {
175
- color: #ffffff;
176
- font-size: 1.5em;
177
- text-decoration: none;
178
- transition: color 0.3s ease;
179
- }
180
-
181
- .navbar .logo a:hover {
182
- color: #4a90e2; /* Hover del logo */
183
- }
184
-
185
- /* Links de navegación */
186
- .nav-links {
187
- display: flex;
188
- gap: 15px;
189
- list-style: none;
190
- margin: 0;
191
- padding: 0;
192
- }
193
-
194
- .nav-links .nav-item {
195
- color: #ffffff;
196
- font-size: 1em;
197
- text-decoration: none;
198
- padding: 8px 15px;
199
- border-radius: 5px;
200
- transition: background-color 0.3s ease, color 0.3s ease;
201
- }
202
-
203
- .nav-links .nav-item:hover {
204
- background-color: #4a90e2; /* Hover */
205
- color: #ffffff;
206
- }
207
-
208
- /* Estilos para dispositivos móviles */
209
- .menu-toggle {
210
- display: none;
211
- }
212
-
213
- @media (max-width: 768px) {
214
- .menu-toggle {
215
- display: inline-block;
216
- font-size: 1.5em;
217
- color: #ffffff;
218
- cursor: pointer;
219
- padding: 8px 15px;
220
- }
221
-
222
- .nav-links {
223
- flex-direction: column;
224
- position: absolute;
225
- top: 100%;
226
- right: 0;
227
- width: 100%;
228
- background-color: #333;
229
- max-height: 0;
230
- overflow: hidden;
231
- transition: max-height 0.3s ease;
232
- }
233
-
234
- /* Activar menú desplegable */
235
- .nav-links.active {
236
- max-height: 300px; /* Ajustar altura */
237
- }
238
-
239
- .nav-links .nav-item {
240
- padding: 10px 20px;
241
- }
242
- }
243
-
244
- /* formularios */
245
- /* Contenedor para centrar el formulario */
246
- .form-wrapper {
247
- display: flex;
248
- justify-content: center;
249
- align-items: center;
250
- margin-top: 50px;
251
- }
252
-
253
- /* Contenedor del formulario */
254
- .form-container {
255
- padding: 20px;
256
- background: black; /* Fondo azul con transparencia */
257
- border-radius: 8px;
258
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
259
- color: white;
260
- text-align: center;
261
- max-width: 400px;
262
- width: 100%;
263
- }
264
-
265
- /* Estilo del formulario */
266
- .form-control {
267
- display: flex;
268
- flex-direction: column;
269
- gap: 15px;
270
- }
271
-
272
- /* Estilo para las etiquetas */
273
- label {
274
- font-size: 0.9em;
275
- color: #d1d5db; /* Color gris claro */
276
- margin-bottom: 5px;
277
- text-align: left;
278
- }
279
-
280
- /* Estilo para los campos de entrada */
281
- input[type="text"],
282
- input[type="password"] {
283
- padding: 10px;
284
- background: rgba(255, 255, 255, 0.2);
285
- border: 1px solid rgba(255, 255, 255, 0.3);
286
- border-radius: 5px;
287
- color: #ffffff;
288
- outline: none;
289
- font-size: 1em;
290
- transition: background 0.3s ease, box-shadow 0.3s ease;
291
- }
292
-
293
- input[type="text"]:focus,
294
- input[type="password"]:focus {
295
- background: rgba(255, 255, 255, 0.4);
296
- box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
297
- }
298
-
299
- /* Estilo del botón */
300
- button[type="submit"] {
301
- padding: 10px;
302
- background: #4a90e2;
303
- color: white;
304
- border: none;
305
- border-radius: 5px;
306
- cursor: pointer;
307
- transition: background 0.3s ease;
308
- }
309
-
310
- button[type="submit"]:hover {
311
- background: #357ab8;
312
- }
313
-
314
- /* alert */
315
-
316
- /* Estilos para la alerta */
317
- .alert {
318
- max-width: 400px;
319
- background-color: #333;
320
- color: #ffffff;
321
- border-radius: 8px;
322
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
323
- margin: 0 auto;
324
- position: relative;
325
- top: 20px;
326
- padding: 15px;
327
- }
328
-
329
- .alert-content {
330
- display: flex;
331
- justify-content: space-between;
332
- align-items: center;
333
- }
334
-
335
- .close-btn {
336
- background: none;
337
- border: none;
338
- cursor: pointer;
339
- color: #ffffff;
340
- transition: color 0.3s ease;
341
- }
342
-
343
- .close-btn:hover {
344
- color: #ff6b6b;
345
- }
346
-
347
- .close-icon {
348
- width: 16px;
349
- height: 16px;
350
- }
351
-
352
- /* logged */
353
-
354
- /* Estilos para el contenedor del bloque */
355
- .layout-container {
356
- display: flex;
357
- justify-content: center;
358
- align-items: center;
359
- height: 100vh;
360
- background-color: #f0f4f8;
361
- font-family: Arial, sans-serif;
362
- }
363
-
364
- /* Estilos para el título */
365
- .layout-container h1 {
366
- font-size: 2.5rem;
367
- color: #4a90e2;
368
- font-weight: bold;
369
- text-align: center;
370
- padding: 20px;
371
- border-radius: 8px;
372
- background: #ffffff;
373
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
374
- }
375
- """)
376
144
  # escritura del archivos que estan en la carpeta layouts
377
145
  write_file(layout_files_path, """{% load static %}
378
146
  <!DOCTYPE html>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: componentsDjangoType
3
- Version: 2.0.31
3
+ Version: 2.0.33
4
4
  Summary: Comandos para crear archivos html, css y js
5
5
  Home-page: https://github.com/jose-CR/componentsDjangoType
6
6
  Author: Alejandro
@@ -18,5 +18,10 @@ componentsDjangoType/management/commands/__pycache__/__init__.cpython-312.pyc
18
18
  componentsDjangoType/management/commands/__pycache__/createApp.cpython-312.pyc
19
19
  services/__init__.py
20
20
  services/authenticator_configurator.py
21
+ services/copy_source.py
21
22
  services/authentication/__init__.py
22
- services/authentication/auth.py
23
+ services/authentication/auth.py
24
+ services/authentication/forms.py
25
+ services/utils/__init__.py
26
+ services/utils/css/__init__.py
27
+ services/utils/js/__init__.py
@@ -1,64 +1,61 @@
1
1
  from django.shortcuts import render, redirect
2
- from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
3
- from django.contrib.auth.models import User
4
- from django.contrib.auth import login, logout, authenticate
2
+ from django.contrib.auth.forms import AuthenticationForm
3
+ from django.contrib.auth import login, logout
5
4
  from django.db import IntegrityError
5
+ from forms import customUserCreationform
6
+
6
7
  class Authentication:
7
8
  @staticmethod
8
9
  def get_signup(request):
9
10
  if request.method == 'GET':
10
11
  return render(request, 'signup.html', {
11
- 'form': UserCreationForm()
12
+ 'form': customUserCreationform
12
13
  })
13
14
  elif request.method == 'POST':
14
- if request.POST['password1'] == request.POST['password2']:
15
+ form = customUserCreationform(request.POST)
16
+ if form.is_valid():
15
17
  try:
16
- # Register user\n"
17
- user = User.objects.create_user(
18
- username=request.POST['username'], password=request.POST['password2'])
19
- user.save()
18
+ user = form.save()
20
19
  login(request, user)
21
20
  return redirect('logged')
22
21
  except IntegrityError:
23
22
  return render(request, 'signup.html', {
24
- 'form': UserCreationForm(),
25
- 'error': 'User already exists'
23
+ 'form': form,
24
+ 'error': 'Unable to register. Please try again later.'
26
25
  })
26
+ else:
27
27
  return render(request, 'signup.html', {
28
- 'form': UserCreationForm(),
29
- 'error': 'Passwords do not match'
30
- })
28
+ 'form': form,
29
+ 'error': 'Please correct the errors below.'
30
+ })
31
+
31
32
  @staticmethod
32
33
  def get_signout(request):
33
34
  logout(request)
34
35
  return redirect('home')
36
+
35
37
  @staticmethod
36
38
  def get_signing(request):
37
39
  if request.method == 'GET':
38
40
  return render(request, 'login.html', {
39
- 'form': AuthenticationForm,
41
+ 'form': AuthenticationForm()
40
42
  })
41
43
  elif request.method == 'POST':
42
- try:
43
- User.objects.get(username=request.POST['username'])
44
- except User.DoesNotExist:
45
- return render(request, 'login.html', {
46
- 'form': AuthenticationForm,
47
- 'error': 'User does not exist in the database'
48
- })
49
- user = authenticate(
50
- request, username=request.POST['username'], password=request.POST['password'])
51
- if user is None:
52
- return render(request, 'login.html', {
53
- 'form': AuthenticationForm,
54
- 'error': 'username or password is incorrect'
55
- })
56
- else:
44
+ form = AuthenticationForm(data=request.POST)
45
+ if form.is_valid():
46
+ user = form.get_user()
57
47
  login(request, user)
58
48
  return redirect('logged')
49
+ else:
50
+ return render(request, 'login.html', {
51
+ 'form': form,
52
+ 'error': 'Invalid username or password. Please try again.'
53
+ })
54
+
59
55
  @staticmethod
60
56
  def get_logged(request):
61
57
  return render(request, 'logged.html')
58
+
62
59
  def dispatch(self, request, *args, **kwargs):
63
60
  match request.path:
64
61
  case "/signup":
@@ -0,0 +1,15 @@
1
+ from django import forms
2
+ from django.contrib.auth.forms import UserCreationForm
3
+ from django.contrib.auth.models import User
4
+
5
+ class customUserCreationform(UserCreationForm):
6
+ class Meta:
7
+ model = User
8
+ fields = ['username', 'password1', 'password2']
9
+
10
+ def clean_username(self):
11
+ username = self.cleaned_data['username']
12
+
13
+ if not username.isalnum():
14
+ raise forms.ValidationError("El nombre de usuario solo puede contener letras y números.")
15
+ return username
@@ -1,6 +1,6 @@
1
1
  import os
2
2
  import ast
3
- from django.core.management.base import BaseCommand
3
+ from services.copy_source import copy_static_file
4
4
  from django.core.management import call_command
5
5
  from services.authentication import auth
6
6
 
@@ -89,31 +89,44 @@ path('', include('home.urls'))
89
89
 
90
90
  updated = False
91
91
 
92
- # Verificar si la ruta de 'Home.urls' está en 'urlpatterns'
93
- if "include('Home.urls')" not in urls_content:
94
- stdout.write("Agregando ruta para 'home.urls'.\n")
95
-
96
- # Agregar importación de 'include'
97
- urls_content = urls_content.replace(
98
- "from django.urls import path",
99
- "from django.urls import path, include"
100
- )
101
-
102
- # Agregar 'Home.urls' a 'urlpatterns'
103
- if "urlpatterns = [" in urls_content:
104
- urls_content = urls_content.replace(
105
- "urlpatterns = [",
106
- "urlpatterns = [\n path('admin/', admin.site.urls),\n path('', include('Home.urls')),\n"
107
- )
92
+ # Verificar si el archivo ya incluye 'include' y 'Home.urls'
93
+ if "include('Home.urls')" not in urls_content or "from django.urls import include" not in urls_content:
94
+ stdout.write("Actualizando el archivo 'urls.py' para incluir 'Home.urls'.\n")
95
+
96
+ # Sobrescribir el contenido del archivo con la estructura deseada
97
+ urls_content = '''"""
98
+ URL configuration for myproject project.
99
+
100
+ The `urlpatterns` list routes URLs to views. For more information please see:
101
+ https://docs.djangoproject.com/en/5.1/topics/http/urls/
102
+ Examples:
103
+ Function views
104
+ 1. Add an import: from my_app import views
105
+ 2. Add a URL to urlpatterns: path('', views.home, name='home')
106
+ Class-based views
107
+ 1. Add an import: from other_app.views import Home
108
+ 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
109
+ Including another URLconf
110
+ 1. Import the include() function: from django.urls import include, path
111
+ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
112
+ """
113
+ from django.contrib import admin
114
+ from django.urls import path, include
115
+
116
+ urlpatterns = [
117
+ path('admin/', admin.site.urls),
118
+ path('', include('Home.urls')),
119
+ ]
120
+ '''
108
121
  updated = True
109
122
 
110
- # Escribir los cambios si se modificó algo
123
+ # Sobrescribir el archivo solo si se actualizó algo
111
124
  if updated:
112
125
  with open(project_urls_path, 'w') as f:
113
126
  f.write(urls_content)
114
- stdout.write(f"El archivo '{project_urls_path}' fue actualizado.\n")
127
+ stdout.write(f"El archivo '{project_urls_path}' ha sido actualizado.\n")
115
128
  else:
116
- stdout.write(f"No fue necesario realizar cambios en '{project_urls_path}'.\n")
129
+ stdout.write(f"No se realizaron cambios en '{project_urls_path}'.\n")
117
130
 
118
131
  def creation_auth(self, stdout):
119
132
  services_dir = os.path.join(self.app_name, 'services')
@@ -121,7 +134,7 @@ path('', include('home.urls'))
121
134
  os.makedirs(authentication_dir, exist_ok=True)
122
135
 
123
136
  # Ruta para el nuevo archivo a crear
124
- authentication_path = os.path.join(authentication_dir, 'authentication.py')
137
+ authentication_path = os.path.join(authentication_dir, 'auth.py')
125
138
 
126
139
  # Usar el atributo __file__ del módulo 'auth' para obtener la ruta del archivo fuente
127
140
  auth_source_path = os.path.abspath(auth.__file__)
@@ -162,7 +175,7 @@ path('', include('home.urls'))
162
175
 
163
176
  # Sobrescribir o crear el archivo views.py
164
177
  views_code = '''from django.shortcuts import render
165
- from Home.services.authentication import Authentication
178
+ from services.authentication.auth import Authentication
166
179
 
167
180
  def home(request):
168
181
  return render(request, 'home.html')
@@ -201,29 +214,31 @@ urlpatterns = [
201
214
  stdout.write(f"El archivo '{urls_path}' ha sido creado.\n")
202
215
  else:
203
216
  stdout.write(f"El archivo '{urls_path}' ya existe.\n")
217
+
204
218
 
219
+ def creation_utils(self, stdout):
205
220
 
221
+ app_name = self.app_name
222
+ #creacion de los directorios
223
+ static_dir = os.path.join(app_name, 'static')
206
224
 
225
+ #creacin de subcarpetas
226
+ js_dir = os.path.join(static_dir, 'js')
227
+ css_dir = os.path.join(static_dir, 'css')
207
228
 
229
+ # Crear las carpetas principales y subcarpetas
230
+ os.makedirs(static_dir, exist_ok=True)
231
+ os.makedirs(js_dir, exist_ok=True)
232
+ os.makedirs(css_dir, exist_ok=True)
208
233
 
234
+ stdout.write("Estructura de carpetas creada.\n")
209
235
 
236
+ files_to_copy = [
237
+ ("services/utils/js/alertErrors.js", os.path.join(js_dir, "alertErrors.js")),
238
+ ("services/utils/css/authentication.css", os.path.join(css_dir, "authentication.css"))
239
+ ]
210
240
 
211
-
212
-
213
-
214
-
215
-
216
-
217
-
218
-
219
-
220
-
221
-
222
-
223
-
224
-
225
-
226
-
227
-
228
-
229
-
241
+ for source_path, destination_path in files_to_copy:
242
+ copy_static_file(source_path, destination_path, stdout)
243
+
244
+ stdout.write("Archivos estáticos copiados.\n")
@@ -0,0 +1,32 @@
1
+ import os
2
+ import shutil
3
+ import sys
4
+
5
+ def copy_static_file(source_path, destination_path, stdout=sys.stdout):
6
+ """
7
+ Copia un archivo estático (HTML, CSS, JS) a una ruta de destino.
8
+
9
+ :param source_path: Ruta completa del archivo fuente.
10
+ :param destination_path: Ruta completa del archivo destino.
11
+ :param stdout: Salida estándar para mensajes (por defecto usa sys.stdout).
12
+ """
13
+ try:
14
+ # Verificar si el archivo fuente existe
15
+ if not os.path.exists(source_path):
16
+ stdout.write(f"El archivo fuente '{source_path}' no existe.\n")
17
+ return
18
+
19
+ # Crear el directorio de destino si no existe
20
+ os.makedirs(os.path.dirname(destination_path), exist_ok=True)
21
+
22
+ # Verificar si el archivo de destino ya existe
23
+ if os.path.exists(destination_path):
24
+ stdout.write(f"El archivo '{destination_path}' ya existe.\n")
25
+ return
26
+
27
+ # Copiar el archivo al destino
28
+ shutil.copy(source_path, destination_path)
29
+ stdout.write(f"El archivo '{source_path}' fue copiado a '{destination_path}'.\n")
30
+
31
+ except Exception as e:
32
+ stdout.write(f"Error al copiar el archivo: {e}\n")
File without changes
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='componentsDjangoType',
5
- version='2.0.31',
5
+ version='2.0.33',
6
6
  packages=find_packages(),
7
7
  include_package_data=True,
8
8
  license='MIT',