Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Marinello
django-password-reset
Commits
7faa1398
Commit
7faa1398
authored
Nov 22, 2014
by
Eduardo Matos
Browse files
pep8 fixes
parent
3a9486e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
password_reset/forms.py
View file @
7faa1398
...
...
@@ -46,8 +46,9 @@ class PasswordRecoveryForm(forms.Form):
self
.
cleaned_data
[
'user'
]
=
user
=
cleaner
(
username
)
from
django.conf
import
settings
recovery_only_active_users
=
getattr
(
settings
,
\
'RECOVER_ONLY_ACTIVE_USERS'
,
False
)
recovery_only_active_users
=
getattr
(
settings
,
'RECOVER_ONLY_ACTIVE_USERS'
,
False
)
if
recovery_only_active_users
and
\
hasattr
(
user
,
'is_active'
)
and
not
user
.
is_active
:
...
...
password_reset/tests/tests.py
View file @
7faa1398
...
...
@@ -94,7 +94,7 @@ class FormTests(TestCase):
},
case_sensitive
=
False
)
self
.
assertTrue
(
form
.
is_valid
())
def
test_
raise_error_if_user_is_inactive_and_settings_doesnt_allow_
inactive_password_recovery
(
self
):
def
test_inactive
_user
_password_recovery
(
self
):
user
=
create_user
()
if
hasattr
(
user
,
'is_active'
):
...
...
@@ -102,20 +102,23 @@ class FormTests(TestCase):
user
.
save
()
form
=
PasswordRecoveryForm
(
data
=
{
'username_or_email'
:
user
.
email
})
self
.
assertTrue
(
form
.
is_valid
(),
'Password from inactive should be recovered'
)
self
.
assertTrue
(
form
.
is_valid
(),
'Password from inactive should be recovered'
)
settings
.
RECOVER_ONLY_ACTIVE_USERS
=
True
form
=
PasswordRecoveryForm
(
data
=
{
'username_or_email'
:
user
.
email
})
self
.
assertFalse
(
form
.
is_valid
(),
'Password from inactive user should not be recovered'
)
self
.
assertFalse
(
form
.
is_valid
(),
'Password from inactive user should '
'not be recovered'
)
self
.
assertItemsEqual
(
form
.
errors
[
'username_or_email'
],
[
u
"Sorry, this user is inactive and his password can't be recovered."
])
[
u
"Sorry, this user is inactive and his "
"password can't be recovered."
])
# tear down settings
del
settings
.
RECOVER_ONLY_ACTIVE_USERS
def
test_form_custom_search
(
self
):
# Searching only for email does some extra validation
form
=
PasswordRecoveryForm
(
data
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment