Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Bug 1116335 - Fix URL reversal for user admin.
Browse files Browse the repository at this point in the history
  • Loading branch information
jezdez committed Apr 24, 2015
1 parent f1b5f2a commit e32cc97
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
19 changes: 9 additions & 10 deletions kuma/users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

class UserAdmin(BaseUserAdmin):
# extend the admin view of users to show date_joined field; add a filter on the field too
list_display = ('username', 'email', 'first_name', 'last_name', 'date_joined', 'is_staff', 'is_active')
list_filter = ('is_staff', 'is_superuser', 'is_active', 'date_joined',)
list_display = ('username', 'email', 'first_name', 'last_name',
'date_joined', 'is_staff', 'is_active')
list_filter = ('is_staff', 'is_superuser', 'is_active', 'date_joined')
ordering = ('-date_joined',)

admin.site.register(User, UserAdmin)
Expand All @@ -31,14 +32,14 @@ class UserBanAdmin(admin.ModelAdmin):
class ProfileAdmin(admin.ModelAdmin):

list_display = ('user_name', 'related_user', 'fullname', 'title',
'organization', 'location','content_flagging_email',
'tags', )
'organization', 'location', 'content_flagging_email',
'tags')

list_editable = ('content_flagging_email', 'tags', )

search_fields = ('user__username', 'homepage', 'title', 'fullname',
'organization', 'location', 'bio', 'misc',
'user__email', 'tags__name', )
'user__email', 'tags__name')

list_filter = ()

Expand All @@ -50,18 +51,16 @@ class ProfileAdmin(admin.ModelAdmin):

def related_user(self, obj):
"""HTML link to related user account"""
link = reverse('admin:auth_user_change', args=(obj.user.id,),
link = reverse('admin:users_user_change', args=(obj.user.id,),
current_app=admin.site.name)
# TODO: Needs l10n? Maybe not a priority for an admin page.
return ('<a href="%(link)s"><strong>User %(id)s</strong></a>' % dict(
link=link, id=obj.user.id, username=obj.user.username))

return ('<a href="%(link)s"><strong>User %(id)s</strong></a>' %
{'link': link, 'id': obj.user.id})
related_user.allow_tags = True
related_user.short_description = 'User account'

def user_name(self, obj):
return obj.user.username

user_name.short_description = 'User name'


Expand Down
10 changes: 5 additions & 5 deletions kuma/users/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def ban_link(context, ban_user, banner_user):


@register.function
@contextfunction
def admin_link(context, user):
def admin_link(user):
"""Returns a link to admin a user"""
link = ''
url = reverse('admin:auth_user_change', args=(user.id,),
url = reverse('admin:users_user_change', args=(user.id,),
current_app=admin.site.name)
link = '<a href="%s" class="button neutral">%s<i aria-hidden="true" class="icon-wrench"></i></a>' % (url, _('Admin'))
link = ('<a href="%s" class="button neutral">%s'
'<i aria-hidden="true" class="icon-wrench"></i></a>' %
(url, _('Admin')))
return Markup(link)


Expand Down

0 comments on commit e32cc97

Please sign in to comment.