Commit 0c52772f authored by Noe Nieto's avatar Noe Nieto 💬

Fix typos; add translations, undo croude changes to form field labels.

parent 04fbc397
Pipeline #5117 failed with stage
from django import forms
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.forms import AuthenticationForm as BaseAuthenticationForm
from django.contrib.auth import get_user_model, password_validation
from django.contrib.auth.forms import UsernameField, AuthenticationForm as BaseAuthenticationForm
from django.utils.translation import ugettext_lazy as _
from registration.forms import RegistrationForm as BaseRegistrationForm
from captcha.fields import CaptchaField
User = get_user_model()
username_title = _(settings.SITE_TITLE + " address")
username_label = _('%(service)s address' % {'service': settings.SITE_TITLE})
class AuthenticationForm(BaseAuthenticationForm):
# this currently has no effect
class Authenticationform(BaseAuthenticationForm):
username = UsernameField(
label=username_label,
max_length=254,
widget=forms.TextInput(attrs={'autofocus': True}),
)
def __init__(self, request=None, *args, **kwargs):
super(AuthenticationForm, self).__init__(request, *args, **kwargs)
self.fields[User.USERNAME_FIELD].label = username_title
self.fields["password"].label = _("Passphrase")
password = forms.CharField(
label=_('Passphrase'),
strip=False,
widget=forms.PasswordInput,
)
class RegistrationForm(BaseRegistrationForm):
captcha = CaptchaField()
email = None # override base definition to remove email field
error_messages = {
'password_mismatch': _("The two passphrase fields didn't match."),
}
password1 = forms.CharField(
label=_("Passphrase"),
strip=False,
widget=forms.PasswordInput,
help_text=_('A good passphrase is made of at least three long words.'),
)
password2 = forms.CharField(
label=_("Passphrase confirmation"),
widget=forms.PasswordInput,
strip=False,
help_text=_("Enter the same Passphrase as before, for verification."),
)
captcha = CaptchaField(
label=_('Are you a robot?')
)
def __init__(self, *args, **kwargs):
super(RegistrationForm, self).__init__(*args, **kwargs)
self.fields[User.USERNAME_FIELD].label = username_title
self.fields["password1"].label = _("Passphrase")
self.fields["password2"].label = _("Passphrase confirmation")
self.fields["password2"].help_text = _("Enter the same passphrase as before, for verification.")
self.fields[User.USERNAME_FIELD].label = username_label
class Meta(BaseRegistrationForm.Meta):
model = User
# override base definition to remove email field
fields = (
User.USERNAME_FIELD,
......
from django.contrib.auth.forms import AuthenticationForm, UsernameField
from django import forms
from django.conf import settings
from django.contrib.auth.views import LoginView
class LdhAuthForm(AuthenticationForm):
username = UsernameField(
label='Librem One addres',
max_length=254,
widget=forms.TextInput(attrs={'autofocus': True}),
)
password = forms.CharField(
label='Passphrase',
strip=False,
widget=forms.PasswordInput,
)
from .forms import Authenticationform
class LdhLoginView(LoginView):
form_class = LdhAuthForm
form_class = Authenticationform
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment