# -*- coding: utf-8 -*-
from __future__ import annotations

from crispy_forms.bootstrap import FormActions
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Submit
from django.contrib.auth.forms import (
    AuthenticationForm as BaseAuthenticationForm,
)
from django.utils.translation import gettext_lazy as _


class LoginForm(BaseAuthenticationForm):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.attrs = {
            'id': self.__class__.__name__,
            'novalidate': '',
        }
        self.helper.layout = Layout(
            'username',
            'password',
            FormActions(
                Submit('submit', _('Log in'), css_class='btn btn-primary'),
                template='ui/ui/forms/formactions.html',
                css_class='mb-0',
            ),
        )
