PonyConf/accounts/forms.py

21 lines
711 B
Python
Raw Normal View History

2017-11-19 20:42:45 +00:00
from django.contrib.auth.forms import AuthenticationForm
2023-03-18 17:30:34 +00:00
from django.utils.translation import gettext_lazy as _
2017-11-19 20:42:45 +00:00
from django.forms.models import modelform_factory
from .models import User, Profile
# email MUST be validated, we do not allow to edit it
UserForm = modelform_factory(User, fields=['first_name', 'last_name', 'username'])
ProfileForm = modelform_factory(Profile, fields=[
'phone_number', 'biography', 'twitter', 'website',
'linkedin', 'facebook', 'mastodon'])
class EmailAuthenticationForm(AuthenticationForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['username'].label = _('Email address')