from django import forms
from django.forms import ValidationError
from django.utils.translation import ugettext as _

from .choices import avatar_filename_choices, display_language_choices


class UserProfileForm(forms.Form):
    first_name = forms.CharField(
        label=_('First Name'),
        required=False,
        max_length=30,
    )

    last_name = forms.CharField(
        label=_('Last Name'),
        required=False,
        max_length=30,
    )

    mail = forms.EmailField(
        label=_('E-mail Address'),
        required=False,
        max_length=256,
    )

    avatar = forms.ChoiceField(
        choices=avatar_filename_choices,
        label=_('Avatar'),
        required=True,
    )

    display_language = forms.ChoiceField(
        choices=display_language_choices,
        label=_('Display Language'),
        required=True,
    )

    def __init__(self, *args, **kvargs):
        super(UserProfileForm, self).__init__(*args, **kvargs)
        self.fields['avatar'].widget.attrs.update({'autofocus': ''})


class LoginForm(forms.Form):
    username = forms.CharField(
        label=_('Username'),
        required=True,
        max_length=256,
    )

    password = forms.CharField(
        label=_('Password'),
        required=True,
        max_length=256,
        widget=forms.PasswordInput(),
    )