Skip to content

Commit

Permalink
Add is_superuser column to User admin. Fix #206
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Feb 12, 2018
1 parent 5d9b9d4 commit 6341886
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tcms/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from django.conf import settings
from django.contrib import admin
from django.http import HttpResponseRedirect
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.contrib.auth.admin import UserAdmin
from django.contrib.sites.admin import SiteAdmin

from django_comments.models import Comment
Expand All @@ -22,8 +24,16 @@ def delete_view(self, request, object_id, extra_context=None):
return HttpResponseRedirect(reverse('admin:sites_site_change', args=[settings.SITE_ID]))


class KiwiUserAdmin(UserAdmin):
list_display = UserAdmin.list_display + ('is_superuser', )


# we don't want comments to be accessible via the admin interface
admin.site.unregister(Comment)
# site admin with limited functionality
admin.site.unregister(Site)
admin.site.register(Site, KiwiSiteAdmin)

# user admin extended functionality
admin.site.unregister(User)
admin.site.register(User, KiwiUserAdmin)
5 changes: 5 additions & 0 deletions tcms/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,8 @@ def test_sites_admin_delete(self):
self.client.login(username=self.tester.username, password='password')
response = self.client.get(reverse('admin:sites_site_delete', args=[settings.SITE_ID]))
self.assertRedirects(response, reverse('admin:sites_site_change', args=[settings.SITE_ID]))

def test_users_list_shows_is_superuser_column(self):
self.client.login(username=self.tester.username, password='password')
response = self.client.get(reverse('admin:auth_user_changelist'))
self.assertContains(response, 'column-is_superuser')

0 comments on commit 6341886

Please sign in to comment.