48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
from django import forms
|
|
from django.contrib.auth.forms import AuthenticationForm, UsernameField
|
|
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": "********"}
|
|
|
|
username = UsernameField(
|
|
widget=forms.EmailInput(
|
|
attrs={
|
|
"autofocus": True,
|
|
"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",
|
|
}
|
|
)
|
|
)
|
|
password = forms.CharField(
|
|
label=_("Contraseña"),
|
|
strip=False,
|
|
widget=forms.PasswordInput(
|
|
attrs={
|
|
"autocomplete": "current-password",
|
|
"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",
|
|
}
|
|
),
|
|
)
|
|
remember_me = forms.BooleanField(
|
|
label=_("Mantener sesión iniciada"),
|
|
required=False,
|
|
widget=forms.CheckboxInput(
|
|
attrs={
|
|
"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"
|
|
}
|
|
),
|
|
)
|