This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor icekit.admin* and icekit.utils.admin.* to icekit.admin_tools…
….*. Previous classes/functions are deprecated.
- Loading branch information
Greg Turner
committed
Mar 5, 2017
1 parent
25bde0a
commit 8cea84f
Showing
27 changed files
with
780 additions
and
482 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,19 @@ | ||
from django.contrib.auth import get_user_model | ||
from django.contrib.auth.forms import PasswordResetForm | ||
import warnings | ||
|
||
warnings.warn( | ||
"the icekit.admin_forms module is deprecated. Use icekit.admin_tools.forms instead.", | ||
DeprecationWarning, | ||
stacklevel=2) | ||
|
||
class PasswordResetForm(PasswordResetForm): | ||
""" | ||
An extended Password reset form designed for staff users. | ||
It limits the users allowed to use this form the send them a | ||
password reset email to staff users only. | ||
""" | ||
def get_users(self, email): | ||
""" | ||
Make sure users are staff users. | ||
|
||
Additionally to the other PasswordResetForm conditions ensure | ||
that the user is a staff user before sending them a password | ||
reset email. | ||
from icekit.utils.deprecation import deprecated | ||
|
||
:param email: Textual email address. | ||
:return: List of users. | ||
""" | ||
# Django 1.8 supports this feature. | ||
if hasattr(super(PasswordResetForm, self), 'get_users'): | ||
return ( | ||
u for u in super(PasswordResetForm, self).get_users(email) | ||
if u.is_staff and u.is_active | ||
) | ||
from icekit.admin_tools.forms import PasswordResetForm as new_PasswordResetForm | ||
|
||
# Django Django < 1.8 support we can do this manually. | ||
active_users = get_user_model()._default_manager.filter(email__iexact=email, is_active=True) | ||
return (u for u in active_users if u.has_usable_password() and u.is_staff and u.is_active) | ||
@deprecated | ||
class PasswordResetForm(new_PasswordResetForm): | ||
""" | ||
.. deprecated:: | ||
Use :class:`icekit.admin_tools.forms.PasswordResetForm` instead. | ||
""" | ||
pass |
Oops, something went wrong.