diff --git a/proyecto/jinja2.py b/proyecto/jinja2.py deleted file mode 100644 index 0916e3b..0000000 --- a/proyecto/jinja2.py +++ /dev/null @@ -1,11 +0,0 @@ -from jinja2 import Environment -from django.urls import reverse -from django.templatetags.static import static - -def environment(**options): - env = Environment(**options) - env.globals.update({ - 'static': static, - 'url': reverse, - }) - return env \ No newline at end of file diff --git a/proyecto/settings.py b/proyecto/settings.py index c866b51..1a9f811 100644 --- a/proyecto/settings.py +++ b/proyecto/settings.py @@ -14,6 +14,7 @@ import logging import os, sys from pathlib import Path +DEV_ENV = (sys.argv[1] == 'runserver') RUNNING_TESTS = any(arg in {'test', 'pytest'} for arg in sys.argv) or 'PYTEST_CURRENT_TEST' in os.environ @@ -101,6 +102,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'django.forms', 'compressor', ] @@ -136,14 +138,6 @@ TEMPLATES = [ ], }, }, - { - 'BACKEND': 'django.template.backends.jinja2.Jinja2', - 'DIRS': [BASE_DIR / 'templates/jinja2'], - 'APP_DIRS': True, - 'OPTIONS': { - 'environment': 'proyecto.jinja2.environment', - }, - } ] WSGI_APPLICATION = 'proyecto.wsgi.application' @@ -429,4 +423,11 @@ CELERY_RESULT_SERIALIZER = 'json' SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") USE_X_FORWARDED_HOST = True -SECURE_REFERER_POLICY = "strict-origin-when-cross-origin" \ No newline at end of file +SECURE_REFERER_POLICY = "strict-origin-when-cross-origin" + +from django.forms.renderers import TemplatesSetting + +class CustomFormRenderer(TemplatesSetting): + form_template_name = "tienda/form_snippet.html" + +FORM_RENDERER = "proyecto.settings.CustomFormRenderer" \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index b1b1161..51c7d4e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,46 +1,51 @@ amqp==5.3.1 -asgiref==3.11.0 +asgiref==3.11.1 billiard==4.2.4 -celery==5.6.2 -certifi==2026.1.4 +boto3==1.43.5 +botocore==1.43.5 +celery==5.6.3 +certifi==2026.4.22 cffi==2.0.0 -charset-normalizer==3.4.4 -click==8.3.1 +charset-normalizer==3.4.7 +click==8.3.3 click-didyoumean==0.3.1 click-plugins==1.1.1.2 click-repl==0.3.0 -cryptography==46.0.7 -Django==6.0.4 +cryptography==48.0.0 +defusedxml==0.7.1 +Django==6.0.5 django-appconf==1.2.0 -django-redis==5.4.0 +django-redis==6.0.0 +django-storages==1.14.6 django_compressor==4.6.0 -django-storages[boto3]==1.14.6 -gunicorn==25.1.0 -idna==3.11 -Jinja2==3.1.6 +fonttools==4.62.1 +fpdf2==2.8.7 +gunicorn==26.0.0 +idna==3.13 + +jmespath==1.1.0 kombu==5.6.2 MarkupSafe==3.0.3 -packaging==26.0 +packaging==26.2 paypalrestsdk==1.13.3 pillow==12.2.0 -boto3==1.42.97 prompt_toolkit==3.0.52 +psycopg2-binary==2.9.12 pycparser==3.0 -pyOpenSSL==26.0.0 +pyOpenSSL==26.2.0 python-dateutil==2.9.0.post0 rcssmin==1.2.2 -redis==5.2.1 -requests==2.33.0 +redis==7.4.0 +requests==2.33.1 rjsmin==1.2.5 +s3transfer==0.17.0 six==1.17.0 sqlparse==0.5.5 -stripe==14.3.0 +stripe==15.1.0 typing_extensions==4.15.0 -tzdata==2025.3 +tzdata==2026.2 tzlocal==5.3.1 urllib3==2.6.3 vine==5.1.0 -wcwidth==0.6.0 +wcwidth==0.7.0 whitenoise==6.12.0 -fpdf2==2.8.7 -psycopg2-binary==2.9.11 \ No newline at end of file diff --git a/tienda/migrations/0008_alter_product_briefdesc_alter_product_description.py b/tienda/migrations/0008_alter_product_briefdesc_alter_product_description.py new file mode 100644 index 0000000..cbef791 --- /dev/null +++ b/tienda/migrations/0008_alter_product_briefdesc_alter_product_description.py @@ -0,0 +1,23 @@ +# Generated by Django 6.0.4 on 2026-05-07 08:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('tienda', '0007_add_product_sku'), + ] + + operations = [ + migrations.AlterField( + model_name='product', + name='briefdesc', + field=models.TextField(default='', max_length=250), + ), + migrations.AlterField( + model_name='product', + name='description', + field=models.TextField(default='', max_length=5000), + ), + ] diff --git a/tienda/models.py b/tienda/models.py index 20a5d4f..d3136e1 100644 --- a/tienda/models.py +++ b/tienda/models.py @@ -86,7 +86,7 @@ class Product(models.Model): name = models.CharField(max_length=200, default="") sku = models.CharField(max_length=50, unique=True, blank=True, null=True) description = models.TextField(default = "", max_length=5000) - briefdesc = models.TextField(default = "", max_length=1000) + briefdesc = models.TextField(default = "", max_length=250) price = models.FloatField(default = 0) stock = models.PositiveIntegerField(default=0) category = models.ForeignKey(Category, on_delete=models.CASCADE) diff --git a/tienda/tasks.py b/tienda/tasks.py index 680016f..480b9d9 100644 --- a/tienda/tasks.py +++ b/tienda/tasks.py @@ -11,21 +11,19 @@ from .models import User, VerificationCode @shared_task def enviar_correo_bienvenida(email_usuario: str, nombre_usuario: str): html_content = render_to_string( - 'emails/welcome.html', + 'tienda/emails/welcome.html', { "name": nombre_usuario }, - using='jinja2' ) send_hemail(email_usuario, "Inicio de Sesión correcto", html_content, "Has iniciado sesión...") @shared_task def banear_usuario(email_usuario: str): html_content = render_to_string( - 'emails/ban.html', + 'tienda/emails/ban.html', { }, - using='jinja2' ) send_hemail(email_usuario, "Cuenta Bloqueada", html_content, "Tu cuenta ha sido bloqueada...") @@ -33,9 +31,8 @@ def banear_usuario(email_usuario: str): @shared_task def desbanear_usuario(email_usuario: str): html_content = render_to_string( - 'emails/unban.html', + 'tienda/emails/unban.html', {}, - using='jinja2' ) send_hemail(email_usuario, "Cuenta Desbloqueada", html_content, "Tu cuenta ha sido desbloqueada...") @@ -67,14 +64,13 @@ def enviar_correo_recuperacion(email: str): ) ver_code.save() html_content = render_to_string( - 'emails/reset_pass.html', + 'tienda/emails/reset_pass.html', { "name": usuario.get_full_name(), "domain": settings.DOMAIN, "protocol": settings.PROTOCOL, "code": ver_code.code }, - using='jinja2' ) send_hemail(email, "Reset de Contraseña", html_content, "Estas reseteando la contraseña...") diff --git a/tienda/templates/tienda/crear_producto.html b/tienda/templates/tienda/crear_producto.html index 87a5b34..22a7a7f 100644 --- a/tienda/templates/tienda/crear_producto.html +++ b/tienda/templates/tienda/crear_producto.html @@ -13,74 +13,7 @@
{% csrf_token %} - - -
- - -
- - -
- - -
Opcional. Se mostrará en las vistas de listado de productos.
-
- - -
- - -
- - -
- -
- - -
-
- - -
- - -
Cantidad máxima que podrán comprar los clientes.
-
- - -
- - -
- - -
- - -
Opcional. Esta será la imagen destacada del producto.
-
- - -
- - -
Opcional. Puedes seleccionar múltiples imágenes adicionales.
-
- + {{ form }}
Cancelar diff --git a/templates/jinja2/emails/ban.html b/tienda/templates/tienda/emails/ban.html similarity index 99% rename from templates/jinja2/emails/ban.html rename to tienda/templates/tienda/emails/ban.html index 1ee10b0..95e2fdb 100644 --- a/templates/jinja2/emails/ban.html +++ b/tienda/templates/tienda/emails/ban.html @@ -24,4 +24,4 @@ - \ No newline at end of file + diff --git a/templates/jinja2/emails/register.html b/tienda/templates/tienda/emails/register.html similarity index 99% rename from templates/jinja2/emails/register.html rename to tienda/templates/tienda/emails/register.html index f08823a..fe51f56 100644 --- a/templates/jinja2/emails/register.html +++ b/tienda/templates/tienda/emails/register.html @@ -18,4 +18,4 @@ - \ No newline at end of file + diff --git a/templates/jinja2/emails/reset_pass.html b/tienda/templates/tienda/emails/reset_pass.html similarity index 99% rename from templates/jinja2/emails/reset_pass.html rename to tienda/templates/tienda/emails/reset_pass.html index 32dc1a9..8041e87 100644 --- a/templates/jinja2/emails/reset_pass.html +++ b/tienda/templates/tienda/emails/reset_pass.html @@ -24,4 +24,4 @@ - \ No newline at end of file + diff --git a/templates/jinja2/emails/unban.html b/tienda/templates/tienda/emails/unban.html similarity index 99% rename from templates/jinja2/emails/unban.html rename to tienda/templates/tienda/emails/unban.html index f1f7e1a..46171c7 100644 --- a/templates/jinja2/emails/unban.html +++ b/tienda/templates/tienda/emails/unban.html @@ -24,4 +24,4 @@ - \ No newline at end of file + diff --git a/templates/jinja2/emails/welcome.html b/tienda/templates/tienda/emails/welcome.html similarity index 99% rename from templates/jinja2/emails/welcome.html rename to tienda/templates/tienda/emails/welcome.html index 2d38bd3..4f12fe1 100644 --- a/templates/jinja2/emails/welcome.html +++ b/tienda/templates/tienda/emails/welcome.html @@ -23,4 +23,4 @@ - \ No newline at end of file + diff --git a/tienda/templates/tienda/form_snippet.html b/tienda/templates/tienda/form_snippet.html new file mode 100644 index 0000000..0c20a4c --- /dev/null +++ b/tienda/templates/tienda/form_snippet.html @@ -0,0 +1,6 @@ +{% for field in form %} +
+ {{ field.errors }} + {{ field.label_tag }} {{ field }} +
+{% endfor %} \ No newline at end of file diff --git a/tienda/templates/tienda/gestionar_imagenes.html b/tienda/templates/tienda/gestionar_imagenes.html new file mode 100644 index 0000000..b511c7d --- /dev/null +++ b/tienda/templates/tienda/gestionar_imagenes.html @@ -0,0 +1,81 @@ +{% extends "tienda/base.html" %} +{% load static %} + +{% block content %} +
+
+
+
+

Gestionar Imágenes

+

Producto: {{ producto.name }}

+
+ ← Volver a Mis Productos +
+ +
+
+
Imagen Principal
+
+
+ {% if producto.primary_image %} + {{ producto.primary_image.alt|default:producto.name }} +

Esta imagen no se puede cambiar desde aquí.

+ {% else %} +

No hay imagen principal asignada.

+ {% endif %} +
+
+ +
+
+
Imágenes Secundarias
+ +
+
+ {% if secondary_images %} +
+ {% for img in secondary_images %} +
+
+ {{ img.alt|default:producto.name }} +
+ + {% csrf_token %} + + +
+
+
+ {% endfor %} +
+ {% else %} +

No hay imágenes secundarias. ¡Agrega una!

+ {% endif %} +
+
+
+
+ + +{% endblock %} \ No newline at end of file diff --git a/tienda/templates/tienda/login.html b/tienda/templates/tienda/login.html index 28e9028..a63a364 100644 --- a/tienda/templates/tienda/login.html +++ b/tienda/templates/tienda/login.html @@ -12,22 +12,7 @@
{% csrf_token %} -
- - -
- -
- - -
- -
- - -
+ {{ form }}
diff --git a/tienda/templates/tienda/mis_productos.html b/tienda/templates/tienda/mis_productos.html index fedfc79..17b4e33 100644 --- a/tienda/templates/tienda/mis_productos.html +++ b/tienda/templates/tienda/mis_productos.html @@ -57,6 +57,7 @@ {{ producto.stock }}
+ Gestionar Imágenes Editar {% csrf_token %} diff --git a/tienda/templates/tienda/register.html b/tienda/templates/tienda/register.html index c648827..72f476b 100644 --- a/tienda/templates/tienda/register.html +++ b/tienda/templates/tienda/register.html @@ -12,33 +12,7 @@ {% csrf_token %} -
- - -
- -
- - -
- -
- - -
La contraseña debe tener al menos 8 caracteres.
-
- -
- - -
- -
- - -
+ {{ form }}
diff --git a/tienda/urls.py b/tienda/urls.py index a473dcb..02fd694 100644 --- a/tienda/urls.py +++ b/tienda/urls.py @@ -18,6 +18,8 @@ urlpatterns = [ path("venta/crear-producto/", views.crear_producto, name="crear_producto"), path("venta/editar-producto//", views.editar_producto, name="editar_producto"), path("venta/borrar-producto//", views.borrar_producto, name="borrar_producto"), + path("venta/gestionar-imagenes//", views.gestionar_imagenes, name="gestionar_imagenes"), + path("venta/gestionar-imagenes//eliminar//", views.eliminar_imagen_secundaria, name="eliminar_imagen_secundaria"), # Carrito path("cart/", views.view_cart, name="view_cart"), path("cart/add//", views.add_to_cart, name="add_to_cart"),