From 03f37d304ab3f9cb2c579ab903fff9fbf94871da Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Mon, 2 Dec 2024 12:13:49 +0100 Subject: [PATCH] fix: moved svg files --- shop/admin.py | 21 +++++ theme/templates/components/theme-switch.html | 4 +- users/forms/login.py | 6 +- web/admin.py | 7 ++ web/migrations/0001_initial.py | 53 +++++++++++ web/models.py | 19 +++- .../components/cart/add_to_cart.html | 6 +- .../components/cart/cart_navbar.html | 24 ++--- web/templates/components/generic/navbar.html | 28 +++--- web/templates/components/icons/add_cart.svg | 5 ++ web/templates/components/icons/burger.svg | 4 + web/templates/components/icons/cart.svg | 5 ++ web/templates/components/icons/dropdown.svg | 6 ++ web/templates/components/icons/like.svg | 17 ++++ web/templates/components/icons/moon.svg | 1 + web/templates/components/icons/remove.svg | 6 ++ web/templates/components/icons/search.svg | 6 ++ web/templates/components/icons/star.svg | 5 ++ web/templates/components/icons/sun.svg | 1 + web/templates/components/icons/user.svg | 5 ++ web/templates/components/product_card.html | 34 ++----- .../components/products/list_filters.html | 7 +- web/templates/users/login.html | 45 +++++----- web/templates/users/reset_password.html | 2 +- web/templates/web/cart_detail.html | 28 ++++++ web/templates/web/product_detail.html | 89 ++----------------- web/templatetags/__init__.py | 0 web/templatetags/web.py | 13 +++ web/urls.py | 9 +- web/utils.py | 2 +- web/views/components.py | 2 +- web/views/users.py | 14 ++- web/views/web.py | 28 +++++- 33 files changed, 310 insertions(+), 192 deletions(-) create mode 100644 web/migrations/0001_initial.py create mode 100644 web/templates/components/icons/add_cart.svg create mode 100644 web/templates/components/icons/burger.svg create mode 100644 web/templates/components/icons/cart.svg create mode 100644 web/templates/components/icons/dropdown.svg create mode 100644 web/templates/components/icons/like.svg create mode 100644 web/templates/components/icons/moon.svg create mode 100644 web/templates/components/icons/remove.svg create mode 100644 web/templates/components/icons/search.svg create mode 100644 web/templates/components/icons/star.svg create mode 100644 web/templates/components/icons/sun.svg create mode 100644 web/templates/components/icons/user.svg create mode 100644 web/templates/web/cart_detail.html create mode 100644 web/templatetags/__init__.py create mode 100644 web/templatetags/web.py diff --git a/shop/admin.py b/shop/admin.py index ce4923e..90c936d 100644 --- a/shop/admin.py +++ b/shop/admin.py @@ -3,6 +3,8 @@ from unfold.admin import ModelAdmin from shop.models import ( Brand, + Cart, + CartItem, Customer, Order, OrderLine, @@ -104,3 +106,22 @@ class ProductBatchAdmin(ModelAdmin): "quantity", "provider", ) + + +@admin.register(Cart) +class ProductBatchAdmin(ModelAdmin): + list_display = ( + "uuid", + "user", + "creation_date", + ) + + +@admin.register(CartItem) +class ProductBatchAdmin(ModelAdmin): + list_display = ( + "id", + "cart", + "product", + "quantity", + ) diff --git a/theme/templates/components/theme-switch.html b/theme/templates/components/theme-switch.html index d678646..3fcef0a 100644 --- a/theme/templates/components/theme-switch.html +++ b/theme/templates/components/theme-switch.html @@ -3,6 +3,6 @@ id="theme-toggle" type="button" class="text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none rounded-lg text-sm p-2.5"> - - + {% include 'components/icons/moon.svg' %} + {% include 'components/icons/sun.svg' %} diff --git a/users/forms/login.py b/users/forms/login.py index 593c432..0b1be59 100644 --- a/users/forms/login.py +++ b/users/forms/login.py @@ -8,7 +8,7 @@ class LoginForm(AuthenticationForm): widget=forms.TextInput( attrs={ "autofocus": True, - "class": "bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600" + "class": "my-2 bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600" "focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600" "dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500", } @@ -20,7 +20,7 @@ class LoginForm(AuthenticationForm): widget=forms.PasswordInput( attrs={ "autocomplete": "current-password", - "class": "bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 " + "class": "my-2 bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 " "focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 " "dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500", } @@ -31,7 +31,7 @@ class LoginForm(AuthenticationForm): required=False, widget=forms.CheckboxInput( attrs={ - "class": "w-4 h-4 border border-gray-300 rounded bg-gray-50 focus:ring-3 focus:ring-primary-300 " + "class": "my-2 border border-gray-300 rounded bg-gray-50 focus:ring-3 focus:ring-primary-300 " "dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-primary-600 dark:ring-offset-gray-800" } ), diff --git a/web/admin.py b/web/admin.py index 8c38f3f..8196e79 100644 --- a/web/admin.py +++ b/web/admin.py @@ -1,3 +1,10 @@ from django.contrib import admin +from unfold.admin import ModelAdmin + +from web.models import WebSettings + # Register your models here. +@admin.register(WebSettings) +class WebSettingsAdmin(ModelAdmin): + pass diff --git a/web/migrations/0001_initial.py b/web/migrations/0001_initial.py new file mode 100644 index 0000000..8ee4864 --- /dev/null +++ b/web/migrations/0001_initial.py @@ -0,0 +1,53 @@ +# Generated by Django 5.1.3 on 2024-12-01 11:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [] + + operations = [ + migrations.CreateModel( + name="WebSettings", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "web_title", + models.CharField(max_length=32, verbose_name="título de la web"), + ), + ( + "web_description", + models.CharField( + blank=True, + default="", + max_length=128, + verbose_name="descripción de la web", + ), + ), + ( + "logo", + models.ImageField( + blank=True, + null=True, + upload_to="assets", + verbose_name="logo de la web", + ), + ), + ], + options={ + "verbose_name": "ajustes de la web", + "verbose_name_plural": "ajustes de la web", + }, + ), + ] diff --git a/web/models.py b/web/models.py index 71a8362..aae4eab 100644 --- a/web/models.py +++ b/web/models.py @@ -1,3 +1,20 @@ from django.db import models +from django.utils.text import gettext_lazy as _ -# Create your models here. +from config.models import SingletonModel + + +class WebSettings(SingletonModel): + web_title = models.CharField( + max_length=32, blank=False, verbose_name=_("título de la web") + ) + web_description = models.CharField( + max_length=128, blank=True, default="", verbose_name=_("descripción de la web") + ) + logo = models.ImageField( + blank=True, null=True, upload_to="assets", verbose_name=_("logo de la web") + ) + + class Meta: + verbose_name = _("ajustes de la web") + verbose_name_plural = _("ajustes de la web") diff --git a/web/templates/components/cart/add_to_cart.html b/web/templates/components/cart/add_to_cart.html index ecd27c8..842797a 100644 --- a/web/templates/components/cart/add_to_cart.html +++ b/web/templates/components/cart/add_to_cart.html @@ -5,11 +5,7 @@ diff --git a/web/templates/components/cart/cart_navbar.html b/web/templates/components/cart/cart_navbar.html index 78c7935..4c8ae35 100644 --- a/web/templates/components/cart/cart_navbar.html +++ b/web/templates/components/cart/cart_navbar.html @@ -9,20 +9,11 @@ Carrito {% endblocktranslate %}({{ cart.items.count }}) - + {% include 'components/icons/cart.svg' %} {% blocktranslate %} Carrito {% endblocktranslate %}({{ cart.items.count }}) - @@ -59,12 +50,7 @@ > {% csrf_token %} {% translate 'Quitar' %} - + {% include 'components/icons/remove.svg' %} @@ -83,6 +69,12 @@ {% if cart.items.count > 0 %} + {% translate 'Ver carrito' %} +
@@ -7,8 +9,9 @@
@@ -56,18 +59,9 @@ id="userDropdownButton1" data-dropdown-toggle="userDropdown1" type="button" class="inline-flex items-center rounded-lg justify-center p-2 hover:bg-gray-100 dark:hover:bg-gray-700 text-sm font-medium leading-none text-gray-900 dark:text-white"> - + {% include 'components/icons/user.svg' %} {% translate 'Mi cuenta' %} - + {% include 'components/icons/dropdown.svg' %} @@ -80,18 +74,16 @@ class="inline-flex items-center rounded-lg justify-center p-2 hover:bg-gray-100 dark:hover:bg-gray-700 text-sm font-medium leading-none text-gray-900 dark:text-white">Inicia sesión {% endif %} +
diff --git a/web/templates/components/icons/add_cart.svg b/web/templates/components/icons/add_cart.svg new file mode 100644 index 0000000..87fa435 --- /dev/null +++ b/web/templates/components/icons/add_cart.svg @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/web/templates/components/icons/burger.svg b/web/templates/components/icons/burger.svg new file mode 100644 index 0000000..3a42d3e --- /dev/null +++ b/web/templates/components/icons/burger.svg @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/web/templates/components/icons/cart.svg b/web/templates/components/icons/cart.svg new file mode 100644 index 0000000..d905072 --- /dev/null +++ b/web/templates/components/icons/cart.svg @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/web/templates/components/icons/dropdown.svg b/web/templates/components/icons/dropdown.svg new file mode 100644 index 0000000..21bc1b1 --- /dev/null +++ b/web/templates/components/icons/dropdown.svg @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/web/templates/components/icons/like.svg b/web/templates/components/icons/like.svg new file mode 100644 index 0000000..87639b3 --- /dev/null +++ b/web/templates/components/icons/like.svg @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/web/templates/components/icons/moon.svg b/web/templates/components/icons/moon.svg new file mode 100644 index 0000000..ffcf60f --- /dev/null +++ b/web/templates/components/icons/moon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/templates/components/icons/remove.svg b/web/templates/components/icons/remove.svg new file mode 100644 index 0000000..4eb017d --- /dev/null +++ b/web/templates/components/icons/remove.svg @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/web/templates/components/icons/search.svg b/web/templates/components/icons/search.svg new file mode 100644 index 0000000..5739e6b --- /dev/null +++ b/web/templates/components/icons/search.svg @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/web/templates/components/icons/star.svg b/web/templates/components/icons/star.svg new file mode 100644 index 0000000..738b998 --- /dev/null +++ b/web/templates/components/icons/star.svg @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/web/templates/components/icons/sun.svg b/web/templates/components/icons/sun.svg new file mode 100644 index 0000000..c885604 --- /dev/null +++ b/web/templates/components/icons/sun.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/templates/components/icons/user.svg b/web/templates/components/icons/user.svg new file mode 100644 index 0000000..f3ef701 --- /dev/null +++ b/web/templates/components/icons/user.svg @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/web/templates/components/product_card.html b/web/templates/components/product_card.html index 1de869e..7de63b2 100644 --- a/web/templates/components/product_card.html +++ b/web/templates/components/product_card.html @@ -17,35 +17,11 @@
- - - - - - - - - + {% include 'components/icons/star.svg' %} + {% include 'components/icons/star.svg' %} + {% include 'components/icons/star.svg' %} + {% include 'components/icons/star.svg' %} + {% include 'components/icons/star.svg' %}

5.0

diff --git a/web/templates/components/products/list_filters.html b/web/templates/components/products/list_filters.html index d23e333..7f7085f 100644 --- a/web/templates/components/products/list_filters.html +++ b/web/templates/components/products/list_filters.html @@ -14,12 +14,7 @@
- + {% include 'components/icons/search.svg' %}
- logo - Shoppy + logo + {{ title }}
Sign in to your account -
+ {% csrf_token %} {% for field in form %} - - {{ field }} - {% endfor %} -{#
#} -{#
#} -{#
#} -{# #} -{#
#} -{#
#} -{# #} -{#
#} -{#
#} -{# #} -{# Forgot password?#} -{# #} -{#
#} + {% if field.id_for_label != 'id_remember_me' %} + + {{ field }} + {% else %} +
+ + {{ field }} +
+ + {% endif %} + + {% endfor %}