Skip to content

Commit

Permalink
Refactoring and add settings to reset password and user recovery emai…
Browse files Browse the repository at this point in the history
…l templates.
  • Loading branch information
wlorenzetti committed Nov 15, 2023
1 parent 6a58099 commit 81b6078
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
15 changes: 8 additions & 7 deletions g3w-admin/base/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
G3WRegistrationForm
)
from usersmanage.views import (
UserRegistrationView,
UsernameRecoveryView,
UsernameRecoveryDoneView
G3WUserRegistrationView,
G3WUsernameRecoveryView,
G3WUsernameRecoveryDoneView,
G3WPasswordResetView
)

from ajax_select import urls as ajax_select_urls
Expand Down Expand Up @@ -142,7 +143,7 @@
),
path(
"accounts/register/",
UserRegistrationView.as_view(
G3WUserRegistrationView.as_view(
extra_context=extra_context_login_page,
form_class=G3WRegistrationForm
),
Expand Down Expand Up @@ -184,7 +185,7 @@
),
path(
'password_reset/',
auth.views.PasswordResetView.as_view(
G3WPasswordResetView.as_view(
extra_context=extra_context_login_page,
form_class=G3WResetPasswordForm
),
Expand All @@ -207,14 +208,14 @@
),
path(
'username_recovery/',
UsernameRecoveryView.as_view(
G3WUsernameRecoveryView.as_view(
extra_context=extra_context_login_page
),
name='username_recovery'
),
path(
'username_recovery/done/',
UsernameRecoveryDoneView.as_view(extra_context=extra_context_login_page),
G3WUsernameRecoveryDoneView.as_view(extra_context=extra_context_login_page),
name='username_recovery_done'
),
]
Expand Down
21 changes: 18 additions & 3 deletions g3w-admin/usersmanage/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def post(self, *args, **kwargs):
'selected': ug in current_user_groups} for ug in user_groups]})


class UserRegistrationView(registration_views.RegistrationView):
class G3WUserRegistrationView(registration_views.RegistrationView):
"""
G3W-ADMIn custom registration view.
"""
Expand Down Expand Up @@ -366,8 +366,23 @@ def send_admin_activation_email(self, user):
fail_silently=False,
)

class G3WUserPasswordRecoveryMixin(object):
"""
A mixin to add SITTINGS paramenter inside the template
"""

extra_email_context = {
'SETTINGS': settings
}

class G3WPasswordResetView(G3WUserPasswordRecoveryMixin, PasswordResetView):
"""
Class for G3W-SUITE of PasswordResetView
"""
pass


class UsernameRecoveryView(PasswordResetView):
class G3WUsernameRecoveryView(G3WUserPasswordRecoveryMixin, PasswordResetView):
"""
A view to recovery username by email, follow the same logic of Password reset.
"""
Expand All @@ -379,7 +394,7 @@ class UsernameRecoveryView(PasswordResetView):
template_name = 'registration/username_recovery_form.html'
title = _('Username recovery')

class UsernameRecoveryDoneView(PasswordResetDoneView):
class G3WUsernameRecoveryDoneView(PasswordResetDoneView):
"""
View for show message to the end user of emailing username.
"""
Expand Down

0 comments on commit 81b6078

Please sign in to comment.