feat: added new settings and styling
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Generated by Django 5.1.3 on 2024-12-01 11:25
|
||||
# Generated by Django 5.1.3 on 2024-12-05 20:12
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
@@ -44,6 +44,127 @@ class Migration(migrations.Migration):
|
||||
verbose_name="logo de la web",
|
||||
),
|
||||
),
|
||||
(
|
||||
"business_name",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
help_text="nombre fiscal del comercio",
|
||||
max_length=128,
|
||||
null=True,
|
||||
verbose_name="nombre de negocio",
|
||||
),
|
||||
),
|
||||
(
|
||||
"business_vat_id",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
max_length=16,
|
||||
null=True,
|
||||
verbose_name="CIF del negocio",
|
||||
),
|
||||
),
|
||||
(
|
||||
"business_brand",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
help_text="marca o nombre comercial que se va a mostrar en la web",
|
||||
max_length=64,
|
||||
null=True,
|
||||
verbose_name="marca de negocio",
|
||||
),
|
||||
),
|
||||
(
|
||||
"business_address",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
max_length=64,
|
||||
null=True,
|
||||
verbose_name="dirección de negocio",
|
||||
),
|
||||
),
|
||||
(
|
||||
"business_state",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
max_length=32,
|
||||
null=True,
|
||||
verbose_name="unidad territorial del negocio",
|
||||
),
|
||||
),
|
||||
(
|
||||
"business_zip",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
max_length=16,
|
||||
null=True,
|
||||
verbose_name="código postal del negocio",
|
||||
),
|
||||
),
|
||||
(
|
||||
"business_phone",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
max_length=16,
|
||||
null=True,
|
||||
verbose_name="número de teléfono de contacto",
|
||||
),
|
||||
),
|
||||
(
|
||||
"business_email",
|
||||
models.EmailField(
|
||||
blank=True,
|
||||
max_length=80,
|
||||
null=True,
|
||||
verbose_name="e-mail de contacto",
|
||||
),
|
||||
),
|
||||
(
|
||||
"business_email_2",
|
||||
models.EmailField(
|
||||
blank=True,
|
||||
max_length=80,
|
||||
null=True,
|
||||
verbose_name="e-mail secundario de contacto",
|
||||
),
|
||||
),
|
||||
(
|
||||
"bg_color",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
default="",
|
||||
max_length=9,
|
||||
null=True,
|
||||
verbose_name="color de fondo",
|
||||
),
|
||||
),
|
||||
(
|
||||
"theme_color",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
default="",
|
||||
max_length=9,
|
||||
null=True,
|
||||
verbose_name="color de tema",
|
||||
),
|
||||
),
|
||||
(
|
||||
"logo_240",
|
||||
models.ImageField(
|
||||
blank=True,
|
||||
null=True,
|
||||
upload_to="assets",
|
||||
verbose_name="logo 240x240",
|
||||
),
|
||||
),
|
||||
(
|
||||
"logo_128",
|
||||
models.ImageField(
|
||||
blank=True,
|
||||
null=True,
|
||||
upload_to="assets",
|
||||
verbose_name="logo 128x128",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "ajustes de la web",
|
||||
|
||||
@@ -15,6 +15,73 @@ class WebSettings(SingletonModel):
|
||||
blank=True, null=True, upload_to="assets", verbose_name=_("logo de la web")
|
||||
)
|
||||
|
||||
business_name = models.CharField(
|
||||
max_length=128,
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name=_("nombre de negocio"),
|
||||
help_text=_("nombre fiscal del comercio"),
|
||||
)
|
||||
business_vat_id = models.CharField(
|
||||
max_length=16, blank=True, null=True, verbose_name=_("CIF del negocio")
|
||||
)
|
||||
business_brand = models.CharField(
|
||||
max_length=64,
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name=_("marca de negocio"),
|
||||
help_text=_("marca o nombre comercial que se va a mostrar en la web"),
|
||||
)
|
||||
|
||||
business_address = models.CharField(
|
||||
max_length=64, blank=True, null=True, verbose_name=_("dirección de negocio")
|
||||
)
|
||||
business_state = models.CharField(
|
||||
max_length=32,
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name=_("unidad territorial del negocio"),
|
||||
)
|
||||
business_zip = models.CharField(
|
||||
max_length=16,
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name=_("código postal del negocio"),
|
||||
)
|
||||
|
||||
business_phone = models.CharField(
|
||||
max_length=16,
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name=_("número de teléfono de contacto"),
|
||||
)
|
||||
business_email = models.EmailField(
|
||||
max_length=80, blank=True, null=True, verbose_name=_("e-mail de contacto")
|
||||
)
|
||||
business_email_2 = models.EmailField(
|
||||
max_length=80,
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name=_("e-mail secundario de contacto"),
|
||||
)
|
||||
|
||||
bg_color = models.CharField(
|
||||
max_length=9,
|
||||
default="",
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name=_("color de fondo"),
|
||||
)
|
||||
theme_color = models.CharField(
|
||||
max_length=9, default="", blank=True, null=True, verbose_name=_("color de tema")
|
||||
)
|
||||
logo_240 = models.ImageField(
|
||||
upload_to="assets", blank=True, null=True, verbose_name=_("logo 240x240")
|
||||
)
|
||||
logo_128 = models.ImageField(
|
||||
upload_to="assets", blank=True, null=True, verbose_name=_("logo 128x128")
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("ajustes de la web")
|
||||
verbose_name_plural = _("ajustes de la web")
|
||||
|
||||
@@ -33,16 +33,13 @@
|
||||
</div>
|
||||
|
||||
<div class="w-full min-w-0 flex-1 space-y-4 md:order-2 md:max-w-md">
|
||||
<a href="#"
|
||||
class="text-base font-medium text-gray-900 hover:underline dark:text-white">{{ item.product.name }}</a>
|
||||
<a href="{% url 'web:product_detail' pk=item.product.pk slug=item.product.slug %}"
|
||||
class="text-base font-medium text-gray-900 hover:underline dark:text-white"
|
||||
>
|
||||
{{ item.product.name }}
|
||||
</a>
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<button type="button"
|
||||
class="inline-flex items-center text-sm font-medium text-gray-500 hover:text-gray-900 hover:underline dark:text-gray-400 dark:hover:text-white">
|
||||
{% include 'components/icons/like.svg' %}
|
||||
{% translate 'Añadir a favoritos' %}
|
||||
</button>
|
||||
|
||||
<form class="flex" hx-post="{% url 'web:delete_cart_item' pk=item.pk %}"
|
||||
hx-swap="none">
|
||||
{% csrf_token %}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
{% for cart_item in cart.items.all %}
|
||||
<div>
|
||||
<a href="#"
|
||||
<a href="{% url 'web:product_detail' pk=cart_item.product.pk slug=cart_item.product.slug %}"
|
||||
class="truncate text-sm font-semibold leading-none text-gray-900 dark:text-white hover:underline">
|
||||
{{ cart_item.product.name }}
|
||||
</a>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{% extends 'theme/base.html' %}
|
||||
{% load i18n %}
|
||||
{% load web %}
|
||||
|
||||
{% block main %}
|
||||
@@ -14,7 +15,7 @@
|
||||
class="w-full bg-white rounded-lg shadow dark:border md:mt-0 sm:max-w-md xl:p-0 dark:bg-gray-800 dark:border-gray-700">
|
||||
<div class="p-6 space-y-4 md:space-y-6 sm:p-8">
|
||||
<h1 class="text-xl font-bold leading-tight tracking-tight text-gray-900 md:text-2xl dark:text-white">
|
||||
Sign in to your account
|
||||
{% translate 'Inicia sesión en tu cuenta' %}
|
||||
</h1>
|
||||
<form action="{% url 'web:login' %}" method="post">
|
||||
{% csrf_token %}
|
||||
@@ -40,11 +41,11 @@
|
||||
{% endfor %}
|
||||
<button
|
||||
class="w-full text-white bg-primary-600 hover:bg-primary-700 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">
|
||||
Login
|
||||
{% translate 'Iniciar sesión' %}
|
||||
</button>
|
||||
<p class="text-sm font-light text-gray-500 dark:text-gray-400">
|
||||
Don’t have an account yet?
|
||||
<a href="#" class="font-medium text-primary-600 hover:underline dark:text-primary-500">Sign up</a>
|
||||
<p class="text-sm font-light text-gray-500 mt-4 dark:text-gray-400">
|
||||
{% translate '¿Aún no tienes cuenta?' %}
|
||||
<a href="#" class="font-medium text-primary-600 hover:underline dark:text-primary-500">{% translate 'Regístrate aquí' %}</a>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -7,6 +7,7 @@ from web.views.web import (
|
||||
cart_detail,
|
||||
delete_cart_item,
|
||||
index,
|
||||
manifest,
|
||||
product_detail,
|
||||
)
|
||||
|
||||
@@ -28,4 +29,6 @@ urlpatterns = [
|
||||
# api
|
||||
path("web/add-cart-item/", add_cart_item, name="add_cart_item"),
|
||||
path("web/delete-cart-item/<int:pk>/", delete_cart_item, name="delete_cart_item"),
|
||||
# manifest
|
||||
path("manifest.json", manifest, name="manifest_json"),
|
||||
]
|
||||
|
||||
+38
-1
@@ -1,4 +1,4 @@
|
||||
from django.http.response import HttpResponse
|
||||
from django.http.response import HttpResponse, JsonResponse
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.text import gettext_lazy as _
|
||||
from django.views.decorators.http import require_http_methods
|
||||
@@ -97,6 +97,43 @@ def delete_cart_item(request, pk, *args, **kwargs):
|
||||
return HttpResponse(status=204, headers={"HX-Trigger": "updated-cart"})
|
||||
|
||||
|
||||
def manifest(request, *args, **kwargs):
|
||||
settings = WebSettings.load()
|
||||
|
||||
data = {
|
||||
"name": settings.web_title,
|
||||
"short_name": settings.web_title,
|
||||
"start_url": "/",
|
||||
"background_color": settings.bg_color,
|
||||
"theme_color": settings.theme_color,
|
||||
"icons": [],
|
||||
"display": "standalone",
|
||||
"orientation": "portrait",
|
||||
}
|
||||
|
||||
if settings.logo_240:
|
||||
data["icons"].append(
|
||||
{
|
||||
"src": settings.logo_240.url,
|
||||
"sizes": "240x240",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any",
|
||||
}
|
||||
)
|
||||
|
||||
if settings.logo_128:
|
||||
data["icons"].append(
|
||||
{
|
||||
"src": settings.logo_128.url,
|
||||
"sizes": "240x240",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any",
|
||||
}
|
||||
)
|
||||
|
||||
return JsonResponse(data)
|
||||
|
||||
|
||||
index = IndexView.as_view()
|
||||
product_detail = ProductDetail.as_view()
|
||||
cart_detail = CartDetail.as_view()
|
||||
|
||||
Reference in New Issue
Block a user