from django import forms
from django.utils.translation import gettext_lazy as _

from wagtail.users.forms import UserCreationForm, UserEditForm


class WagtailUserEditForm(UserEditForm):
    """
    Override the wagtail userform so we can edit users created by oscar without
    being required to enter a first and last name.
    """

    first_name = forms.CharField(required=False, label=_("First Name"))
    last_name = forms.CharField(required=False, label=_("Last Name"))
    is_superuser = forms.BooleanField(
        label=_("Administrator"),
        required=False,
        help_text=_(
            "Administrators have full access to manage any object or setting. (implies Webshop administrator)"
        ),
    )
    is_staff = forms.BooleanField(
        label=_("Webshop administrator"),
        required=False,
        help_text=_(
            "Gives full access to any webshop items, like product management and orders."
        ),
    )

    class Meta(UserEditForm.Meta):
        fields = UserEditForm.Meta.fields | {"is_staff"}


class WagtailUserCreateForm(UserCreationForm):
    """
    Override the wagtail userform so we can edit users created by oscar without
    being required to enter a first and last name.
    """

    first_name = forms.CharField(required=False, label=_("First Name"))
    last_name = forms.CharField(required=False, label=_("Last Name"))
    is_superuser = forms.BooleanField(
        label=_("Administrator"),
        required=False,
        help_text=_(
            "Administrators have full access to manage any object or setting. (implies Webshop administrator)"
        ),
    )
    is_staff = forms.BooleanField(
        label=_("Webshop administrator"),
        required=False,
        help_text=_(
            "Gives full access to any webshop items, like product management and orders."
        ),
    )

    class Meta(UserCreationForm.Meta):
        fields = UserCreationForm.Meta.fields | {"is_staff"}
