Skip to content

Commit

Permalink
Add a CustomWagtailUserCreationForm to fix issue with creating users … (
Browse files Browse the repository at this point in the history
HyphaApp#3664)

…from Wagtail admin when Show consent checkbox was set.

Fixes HyphaApp#3649
  • Loading branch information
frjo authored Nov 24, 2023
1 parent 40f78e2 commit bed63da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions hypha/apply/users/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def __init__(self, *args, **kwargs):


class CustomUserAdminFormBase:
error_messages = {
"duplicate_username": _("A user with that email already exists."),
"password_mismatch": _("The two password fields didn't match."),
}

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

Expand All @@ -67,12 +72,11 @@ class CustomUserEditForm(CustomUserAdminFormBase, UserEditForm):
pass


class CustomUserCreationForm(CustomUserAdminFormBase, UserCreationForm):
error_messages = {
"duplicate_username": _("A user with that email already exists."),
"password_mismatch": _("The two password fields didn't match."),
}
class CustomWagtailUserCreationForm(CustomUserAdminFormBase, UserCreationForm):
pass


class CustomUserCreationForm(CustomUserAdminFormBase, UserCreationForm):
def __init__(self, request=None, *args, **kwargs):
self.request = request
super().__init__(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion hypha/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
WAGTAILIMAGES_IMAGE_MODEL = "images.CustomImage"
WAGTAILIMAGES_FEATURE_DETECTION_ENABLED = False
WAGTAIL_USER_EDIT_FORM = "hypha.apply.users.forms.CustomUserEditForm"
WAGTAIL_USER_CREATION_FORM = "hypha.apply.users.forms.CustomUserCreationForm"
WAGTAIL_USER_CREATION_FORM = "hypha.apply.users.forms.CustomWagtailUserCreationForm"
WAGTAIL_USER_CUSTOM_FIELDS = ["full_name"]
WAGTAIL_PASSWORD_MANAGEMENT_ENABLED = False
WAGTAILUSERS_PASSWORD_ENABLED = False
Expand Down

0 comments on commit bed63da

Please sign in to comment.