Skip to content

Commit

Permalink
[#32] Remove user password field only in view permission.
Browse files Browse the repository at this point in the history
  • Loading branch information
lefterisnik committed Dec 29, 2017
1 parent c70d2da commit 13be096
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions admin_view_permission/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ def get_readonly_fields(self, request, obj=None):
except ValueError:
pass

# Special case for User model
if get_model_name(self.model) == settings.AUTH_USER_MODEL:
try:
readonly_fields.remove('password')
except ValueError:
pass

# Remove from the readonly_fields list the excluded fields
# specified on the form or the modeladmin
excluded_fields = self.get_excluded_fields()
Expand All @@ -184,13 +191,6 @@ def get_readonly_fields(self, request, obj=None):
f for f in readonly_fields if f not in excluded_fields
]

# Special case for User model
if get_model_name(self.model) == settings.AUTH_USER_MODEL:
try:
readonly_fields.remove('password')
except ValueError:
pass

return tuple(readonly_fields)

def get_actions(self, request):
Expand Down

0 comments on commit 13be096

Please sign in to comment.