From e0aa611a3087f3be121af4abad58841362d16823 Mon Sep 17 00:00:00 2001 From: Alan Greenblatt Date: Fri, 29 Jun 2018 12:32:42 -0400 Subject: [PATCH 1/2] Check for password_field is not None before attempting to set its help_text in AdminViewPermissionUserAdmin.get_form() --- admin_view_permission/admin.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/admin_view_permission/admin.py b/admin_view_permission/admin.py index 9a25dff..068b2eb 100644 --- a/admin_view_permission/admin.py +++ b/admin_view_permission/admin.py @@ -347,15 +347,15 @@ def get_form(self, request, obj=None, **kwargs): else: password_field = None - # TODO: I don't like this at all. Find another way to change the - # TODO: help_text - if not self._has_change_only_permission(request): - password_field.help_text = _( - "Raw passwords are not stored, so there is no way to see this " - "user's password." - ) - else: - if password_field: + if password_field: + # TODO: I don't like this at all. Find another way to change the + # TODO: help_text + if not self._has_change_only_permission(request): + password_field.help_text = _( + "Raw passwords are not stored, so there is no way to see this " + "user's password." + ) + else: password_field.help_text = _( "Raw passwords are not stored, so there is no way to see " "this user's password, but you can change the password " From c3afbd139a454b45af7998a3124553e476ec2a41 Mon Sep 17 00:00:00 2001 From: Alan Greenblatt Date: Wed, 4 Jul 2018 00:16:14 -0400 Subject: [PATCH 2/2] Minor reformat to obey 80 char limit --- admin_view_permission/admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin_view_permission/admin.py b/admin_view_permission/admin.py index 068b2eb..eb91194 100644 --- a/admin_view_permission/admin.py +++ b/admin_view_permission/admin.py @@ -352,8 +352,8 @@ def get_form(self, request, obj=None, **kwargs): # TODO: help_text if not self._has_change_only_permission(request): password_field.help_text = _( - "Raw passwords are not stored, so there is no way to see this " - "user's password." + "Raw passwords are not stored, so there is no way to " + "see this user's password." ) else: password_field.help_text = _(