fix: styling
This commit is contained in:
@@ -2,8 +2,16 @@ from django import forms
|
|||||||
from django.contrib.auth.forms import AuthenticationForm, UsernameField
|
from django.contrib.auth.forms import AuthenticationForm, UsernameField
|
||||||
from django.utils.text import gettext_lazy as _
|
from django.utils.text import gettext_lazy as _
|
||||||
|
|
||||||
|
from web.mixins import StylingMixin
|
||||||
|
|
||||||
|
|
||||||
|
class LoginForm(StylingMixin, AuthenticationForm):
|
||||||
|
styled_fields = ['username', 'password', ]
|
||||||
|
placeholder_for_field = {
|
||||||
|
"username": _("pablo@shoppy.com"),
|
||||||
|
"password": "********"
|
||||||
|
}
|
||||||
|
|
||||||
class LoginForm(AuthenticationForm):
|
|
||||||
username = UsernameField(
|
username = UsernameField(
|
||||||
widget=forms.EmailInput(
|
widget=forms.EmailInput(
|
||||||
attrs={
|
attrs={
|
||||||
|
|||||||
+12
-1
@@ -2,10 +2,21 @@ from django import forms
|
|||||||
from django.contrib.auth.forms import BaseUserCreationForm, SetPasswordMixin
|
from django.contrib.auth.forms import BaseUserCreationForm, SetPasswordMixin
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.forms import EmailField
|
from django.forms import EmailField
|
||||||
|
from django.utils.text import gettext_lazy as _
|
||||||
|
|
||||||
|
from web.mixins import StylingMixin
|
||||||
|
|
||||||
|
|
||||||
class RegisterForm(BaseUserCreationForm, SetPasswordMixin):
|
class RegisterForm(StylingMixin, BaseUserCreationForm, SetPasswordMixin):
|
||||||
password1, password2 = SetPasswordMixin.create_password_fields()
|
password1, password2 = SetPasswordMixin.create_password_fields()
|
||||||
|
styled_fields = ["email", "first_name", "last_name", "password1", "password2"]
|
||||||
|
placeholder_for_field = {
|
||||||
|
"email": _('pablo@shoppy.com'),
|
||||||
|
"first_name": _("Pablo"),
|
||||||
|
"last_name": _("Moreno"),
|
||||||
|
"password1": "********",
|
||||||
|
"password2": "********",
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|||||||
@@ -5,12 +5,23 @@ from django.contrib.auth.tokens import default_token_generator
|
|||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils.text import gettext_lazy as _
|
from django.utils.text import gettext_lazy as _
|
||||||
|
|
||||||
|
from web.mixins import StylingMixin
|
||||||
class PasswordResetForm(BasePasswordResetForm):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class SetPasswordForm(BaseSetPasswordForm):
|
class PasswordResetForm(StylingMixin, BasePasswordResetForm):
|
||||||
|
styled_fields = ['email', ]
|
||||||
|
placeholder_for_field = {
|
||||||
|
"email": _("pablo@shoppy.com"),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class SetPasswordForm(StylingMixin, BaseSetPasswordForm):
|
||||||
|
styled_fields = ['new_password1', 'new_password2', ]
|
||||||
|
placeholder_for_field = {
|
||||||
|
"new_password1": "********",
|
||||||
|
"new_password2": "********",
|
||||||
|
}
|
||||||
|
|
||||||
token = forms.CharField(
|
token = forms.CharField(
|
||||||
required=True,
|
required=True,
|
||||||
widget=forms.HiddenInput(),
|
widget=forms.HiddenInput(),
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ def web_settings(request):
|
|||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
"web_title": settings.web_title,
|
||||||
"logo": settings.logo.url if settings.logo else "",
|
"logo": settings.logo.url if settings.logo else "",
|
||||||
"navbar_categories": navbar_categories,
|
"navbar_categories": navbar_categories,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
|
from django.utils.text import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
class FilteredQuerysetMixin:
|
class FilteredQuerysetMixin:
|
||||||
@@ -25,3 +26,32 @@ class PaginatedQuerysetMixin:
|
|||||||
page = self.request.GET.get("page", 1)
|
page = self.request.GET.get("page", 1)
|
||||||
qs = paginator.get_page(page)
|
qs = paginator.get_page(page)
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
|
||||||
|
class StylingMixin:
|
||||||
|
placeholder_for_field = {}
|
||||||
|
styled_fields = []
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.style_fields()
|
||||||
|
|
||||||
|
def style_fields(self):
|
||||||
|
for field_name in self.styled_fields:
|
||||||
|
field = self.fields[field_name]
|
||||||
|
field.required = True
|
||||||
|
field.widget.attrs.update(
|
||||||
|
{
|
||||||
|
"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-primary-500 "
|
||||||
|
"dark:focus:border-primary-500"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if self.placeholder_for_field.get(field_name):
|
||||||
|
field.widget.attrs.update(
|
||||||
|
{
|
||||||
|
"placeholder": self.placeholder_for_field.get(field_name),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
Hola madafaka
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{% load i18n %}{% autoescape off %}
|
||||||
|
{% blocktranslate %}Password reset on {{ site_name }}{% endblocktranslate %}
|
||||||
|
{% endautoescape %}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
<a href="{% url 'web:index' %}"
|
<a href="{% url 'web:index' %}"
|
||||||
class="flex items-center mb-6 text-2xl font-semibold text-gray-900 dark:text-white">
|
class="flex items-center mb-6 text-2xl font-semibold text-gray-900 dark:text-white">
|
||||||
<img class="w-8 h-8 mr-2" src="{{ logo }}" alt="logo">
|
<img class="w-8 h-8 mr-2" src="{{ logo }}" alt="logo">
|
||||||
{{ title }}
|
{{ web_title }}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<a href="{% url 'web:index' %}" class="flex items-center mb-6 text-2xl font-semibold text-gray-900 dark:text-white">
|
<a href="{% url 'web:index' %}" class="flex items-center mb-6 text-2xl font-semibold text-gray-900 dark:text-white">
|
||||||
<img class="w-8 h-8 mr-2" src="{{ logo }}" alt="logo">
|
<img class="w-8 h-8 mr-2" src="{{ logo }}" alt="logo">
|
||||||
{{ title }}
|
{{ web_title }}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<a href="{% url 'web:index' %}" class="flex items-center mb-6 text-2xl font-semibold text-gray-900 dark:text-white">
|
<a href="{% url 'web:index' %}" class="flex items-center mb-6 text-2xl font-semibold text-gray-900 dark:text-white">
|
||||||
<img class="w-8 h-8 mr-2" src="{{ logo }}" alt="logo">
|
<img class="w-8 h-8 mr-2" src="{{ logo }}" alt="logo">
|
||||||
{{ title }}
|
{{ web_title }}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% for field in form %}
|
{% for field in form %}
|
||||||
|
|
||||||
<div class="my-2 flex items-center">
|
<div class="my-2">
|
||||||
<label for="{{ field.id_for_label }}"
|
<label for="{{ field.id_for_label }}"
|
||||||
class="inline-block text-sm font-medium text-gray-900 dark:text-white mr-2">
|
class="inline-block text-sm font-medium text-gray-900 dark:text-white mr-2">
|
||||||
{{ field.label }}
|
{{ field.label }}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<a href="{% url 'web:index' %}" class="flex items-center mb-6 text-2xl font-semibold text-gray-900 dark:text-white">
|
<a href="{% url 'web:index' %}" class="flex items-center mb-6 text-2xl font-semibold text-gray-900 dark:text-white">
|
||||||
<img class="w-8 h-8 mr-2" src="{{ logo }}" alt="logo">
|
<img class="w-8 h-8 mr-2" src="{{ logo }}" alt="logo">
|
||||||
{{ title }}
|
{{ web_title }}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% for field in form %}
|
{% for field in form %}
|
||||||
|
|
||||||
<div class="my-2 flex items-center">
|
<div class="my-2">
|
||||||
<label for="{{ field.id_for_label }}"
|
<label for="{{ field.id_for_label }}"
|
||||||
class="inline-block text-sm font-medium text-gray-900 dark:text-white mr-2">
|
class="inline-block text-sm font-medium text-gray-900 dark:text-white mr-2">
|
||||||
{{ field.label }}
|
{{ field.label }}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<a href="{% url 'web:index' %}"
|
<a href="{% url 'web:index' %}"
|
||||||
class="flex items-center mb-6 text-2xl font-semibold text-gray-900 dark:text-white">
|
class="flex items-center mb-6 text-2xl font-semibold text-gray-900 dark:text-white">
|
||||||
<img class="w-8 h-8 mr-2" src="{{ logo }}" alt="logo">
|
<img class="w-8 h-8 mr-2" src="{{ logo }}" alt="logo">
|
||||||
{{ title }}
|
{{ web_title }}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
{{ product.price.price_with_tax }} €
|
{{ product.price.price_with_tax }} €
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<!--
|
||||||
<div class="flex items-center gap-2 mt-2 sm:mt-0">
|
<div class="flex items-center gap-2 mt-2 sm:mt-0">
|
||||||
<div class="flex items-center gap-1">
|
<div class="flex items-center gap-1">
|
||||||
{% include 'components/icons/star.svg' %}
|
{% include 'components/icons/star.svg' %}
|
||||||
@@ -48,6 +49,7 @@
|
|||||||
345 Reviews
|
345 Reviews
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="my-4 sm:gap-4 items-center flex sm:m-8">
|
<div class="my-4 sm:gap-4 items-center flex sm:m-8">
|
||||||
|
|||||||
+9
-3
@@ -129,14 +129,13 @@ class ResetPasswordView(TemplateView):
|
|||||||
template_name = "users/reset_password.html"
|
template_name = "users/reset_password.html"
|
||||||
form_class = PasswordResetForm
|
form_class = PasswordResetForm
|
||||||
redirect_to = "web:reset_password_email_sent"
|
redirect_to = "web:reset_password_email_sent"
|
||||||
email_reset_password_template_name = "mails/reset_password.txt"
|
|
||||||
html_reset_password_template_name = "mails/reset_password.html"
|
html_reset_password_template_name = "mails/reset_password.html"
|
||||||
subject_template_name = "mails/subject_reset_password.txt"
|
subject_template_name = "mails/subject_reset_password.txt"
|
||||||
|
|
||||||
def get_email_options(self):
|
def get_email_options(self):
|
||||||
return {
|
return {
|
||||||
"extra_email_context": {},
|
"extra_email_context": {},
|
||||||
"email_template_name": self.email_reset_password_template_name,
|
"email_template_name": self.html_reset_password_template_name,
|
||||||
"html_email_template_name": self.html_reset_password_template_name,
|
"html_email_template_name": self.html_reset_password_template_name,
|
||||||
"subject_template_name": self.subject_template_name,
|
"subject_template_name": self.subject_template_name,
|
||||||
}
|
}
|
||||||
@@ -177,6 +176,14 @@ class ResetPasswordView(TemplateView):
|
|||||||
class ResetPasswordEmailSent(TemplateView):
|
class ResetPasswordEmailSent(TemplateView):
|
||||||
template_name = "users/reset_password_email_sent.html"
|
template_name = "users/reset_password_email_sent.html"
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
settings = WebSettings.load()
|
||||||
|
|
||||||
|
return {
|
||||||
|
"title": settings.web_title,
|
||||||
|
"description": settings.web_description,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class ResetPasswordConfirmView(TemplateView):
|
class ResetPasswordConfirmView(TemplateView):
|
||||||
template_name = "users/reset_password_confirm.html"
|
template_name = "users/reset_password_confirm.html"
|
||||||
@@ -237,7 +244,6 @@ class MyAccountView(TemplateView):
|
|||||||
addresses = CustomerAddress.objects.filter(user=self.request.user)
|
addresses = CustomerAddress.objects.filter(user=self.request.user)
|
||||||
settings = WebSettings.load()
|
settings = WebSettings.load()
|
||||||
return {
|
return {
|
||||||
"web_title": settings.web_title,
|
|
||||||
"customer_addresses": addresses,
|
"customer_addresses": addresses,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-9
@@ -32,7 +32,6 @@ class IndexView(TemplateView):
|
|||||||
settings = WebSettings.load()
|
settings = WebSettings.load()
|
||||||
return {
|
return {
|
||||||
"title": settings.web_title,
|
"title": settings.web_title,
|
||||||
"web_title": settings.web_title,
|
|
||||||
"description": settings.web_description,
|
"description": settings.web_description,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,8 +45,7 @@ class CategoryView(TemplateView):
|
|||||||
category = ProductCategory.objects.get(slug=slug)
|
category = ProductCategory.objects.get(slug=slug)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"title": settings.web_title,
|
"title": _(f'{settings.web_title} - {category.name}'),
|
||||||
"web_title": settings.web_title,
|
|
||||||
"description": settings.web_description,
|
"description": settings.web_description,
|
||||||
"category": category,
|
"category": category,
|
||||||
"filter_by_category": True,
|
"filter_by_category": True,
|
||||||
@@ -63,8 +61,7 @@ class ProductDetail(TemplateView):
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
"product": product,
|
"product": product,
|
||||||
"title": product.name,
|
"title": f'{settings.web_title} - {product.name}',
|
||||||
"web_title": settings.web_title,
|
|
||||||
"description": product.description,
|
"description": product.description,
|
||||||
"image": product.images.first(),
|
"image": product.images.first(),
|
||||||
}
|
}
|
||||||
@@ -82,7 +79,6 @@ class CartDetail(TemplateView, CreateView):
|
|||||||
return {
|
return {
|
||||||
"cart": cart,
|
"cart": cart,
|
||||||
"items": cart_items,
|
"items": cart_items,
|
||||||
"web_title": web_settings.web_title,
|
|
||||||
"description": _("resumen del carrito"),
|
"description": _("resumen del carrito"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +165,6 @@ class OrderDetail(TemplateView):
|
|||||||
settings = WebSettings.load()
|
settings = WebSettings.load()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"web_title": settings.web_title,
|
|
||||||
"order": order,
|
"order": order,
|
||||||
"items": items,
|
"items": items,
|
||||||
"signature_version": parameters.get("Ds_SignatureVersion"),
|
"signature_version": parameters.get("Ds_SignatureVersion"),
|
||||||
@@ -190,7 +185,6 @@ class WishlistView(TemplateView):
|
|||||||
settings = WebSettings.load()
|
settings = WebSettings.load()
|
||||||
return {
|
return {
|
||||||
"title": settings.web_title,
|
"title": settings.web_title,
|
||||||
"web_title": settings.web_title,
|
|
||||||
"description": settings.web_description,
|
"description": settings.web_description,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +204,6 @@ class OrdersView(TemplateView, FilteredQuerysetMixin, PaginatedQuerysetMixin):
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
"title": settings.web_title,
|
"title": settings.web_title,
|
||||||
"web_title": settings.web_title,
|
|
||||||
"page": page,
|
"page": page,
|
||||||
"has_next_page": page.has_next(),
|
"has_next_page": page.has_next(),
|
||||||
"has_previous_page": page.has_previous(),
|
"has_previous_page": page.has_previous(),
|
||||||
|
|||||||
Reference in New Issue
Block a user