diff --git a/test_project/core/admin.py b/test_project/core/admin.py index f46dc26..465e77f 100644 --- a/test_project/core/admin.py +++ b/test_project/core/admin.py @@ -15,6 +15,15 @@ admin.site.unregister(User) +class ZaibatsuAdminSite(admin.AdminSite): + site_header = 'Zaibatsu Admin' + site_title = 'Zaibatsu Admin Portal' + index_title = 'Welcome to Zaibatsu Admin Portal' + + +zaibatsu_admin_site = ZaibatsuAdminSite(name='zaibatsu') + + class AuthorField(StrField): name = 'author' model = Book @@ -137,7 +146,6 @@ def get_fields(self, model): return fields -@admin.register(User) class CustomUserAdmin(DjangoQLSearchMixin, UserAdmin): djangoql_schema = UserQLSchema search_fields = ('username', 'first_name', 'last_name') @@ -153,3 +161,7 @@ def get_queryset(self, request): return qs.\ annotate(groups_count=Count('groups')).\ prefetch_related('groups') + + +admin.site.register(User, CustomUserAdmin) +zaibatsu_admin_site.register(User, CustomUserAdmin) diff --git a/test_project/core/tests/test_admin.py b/test_project/core/tests/test_admin.py index 969450b..a3af7dd 100644 --- a/test_project/core/tests/test_admin.py +++ b/test_project/core/tests/test_admin.py @@ -35,6 +35,16 @@ def test_introspections(self): for model in ('core.book', 'auth.user', 'auth.group'): self.assertIn(model, introspections['models']) + def test_introspection_suggestion_api_url(self): + self.assertTrue(self.client.login(**self.credentials)) + for app in ['admin', 'zaibatsu']: + url = reverse('%s:auth_user_djangoql_introspect' % app) + introspections = self.get_json(url) + self.assertEqual( + reverse('%s:auth_user_djangoql_suggestions' % app), + introspections['suggestions_api_url'], + ) + def test_djangoql_syntax_help(self): url = reverse('admin:djangoql_syntax_help') # unauthorized request should be redirected diff --git a/test_project/test_project/urls.py b/test_project/test_project/urls.py index 8259ba3..213f079 100644 --- a/test_project/test_project/urls.py +++ b/test_project/test_project/urls.py @@ -26,11 +26,13 @@ except ImportError: # Django < 2.0 from django.conf.urls import url as re_path +from core.admin import zaibatsu_admin_site from core.views import completion_demo urlpatterns = [ re_path(r'^admin/', admin.site.urls), + re_path(r'^zaibatsu-admin/', zaibatsu_admin_site.urls), re_path(r'^$', completion_demo), ]