Fix "admin/auth/user/add "username" missing field.

Add test for PR `fix_username_missing_field`

Update test case. Remove blank line whitespace.
This commit is contained in:
Dmitry Gamanenko
2017-12-21 05:56:21 -05:00
committed by Dmitry Gamanenko
parent 2f52e81d28
commit df9dec9b88
2 changed files with 19 additions and 8 deletions

View File

@@ -195,14 +195,15 @@ class UserAdmin(BaseUserAdmin):
""" Admin interface for the User model. """
inlines = (UserProfileInline,)
def get_readonly_fields(self, *args, **kwargs):
def get_readonly_fields(self, request, obj=None):
"""
Allows editing the users while skipping the username check, so we can have Unicode username with no problems.
The username is marked read-only regardless of `ENABLE_UNICODE_USERNAME`, to simplify the bokchoy tests.
The username is marked read-only when editing existing users regardless of `ENABLE_UNICODE_USERNAME`, to simplify the bokchoy tests.
"""
django_readonly = super(UserAdmin, self).get_readonly_fields(*args, **kwargs)
return django_readonly + ('username',)
django_readonly = super(UserAdmin, self).get_readonly_fields(request, obj)
if obj:
return django_readonly + ('username',)
return django_readonly
@admin.register(UserAttribute)