Skip to content
Snippets Groups Projects
Commit 889903c8 authored by Dan Braghis's avatar Dan Braghis
Browse files

Use a common base class for the custom admin form classes

parent 7245bb58
No related branches found
No related tags found
No related merge requests found
......@@ -3,8 +3,7 @@ from django.utils.translation import ugettext_lazy as _
from wagtail.wagtailusers.forms import UserEditForm, UserCreationForm
class CustomUserEditForm(UserEditForm):
class CustomUserAdminFormBase():
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
......@@ -12,10 +11,8 @@ class CustomUserEditForm(UserEditForm):
self.fields['first_name'].widget = forms.HiddenInput(attrs={'value': f"Not used - see full_name"})
self.fields['last_name'].widget = forms.HiddenInput(attrs={'value': f"Not used - see full_name"})
class CustomUserCreationForm(UserCreationForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
class CustomUserEditForm(CustomUserAdminFormBase, UserEditForm):
pass
# HACK: Wagtail admin doesn't work with custom User models that do not have first/last name.
self.fields['first_name'].widget = forms.HiddenInput(attrs={'value': f"Not used - see full_name"})
self.fields['last_name'].widget = forms.HiddenInput(attrs={'value': f"Not used - see full_name"})
class CustomUserCreationForm(CustomUserAdminFormBase, UserCreationForm):
pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment