From eca74aae6bd7ebea5ee1f9c18f66e73c2ed9e62e Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sat, 16 Feb 2019 09:53:42 +0100 Subject: [PATCH] Add custom admin site for users --- re2o/admin.py | 10 ++++++++++ re2o/urls.py | 2 ++ 2 files changed, 12 insertions(+) create mode 100644 re2o/admin.py diff --git a/re2o/admin.py b/re2o/admin.py new file mode 100644 index 00000000..fb680a83 --- /dev/null +++ b/re2o/admin.py @@ -0,0 +1,10 @@ +from django.contrib.admin.sites import AdminSite + + +class UserAdmin(AdminSite): + def has_permission(self, request): + """This admin site doesn't require being staff""" + return request.user.is_active + + +user_admin_site = UserAdmin(name='user_admin') diff --git a/re2o/urls.py b/re2o/urls.py index 39f51ec3..ee3f56fa 100644 --- a/re2o/urls.py +++ b/re2o/urls.py @@ -48,6 +48,7 @@ from django.conf.urls import include, url from django.contrib import admin from django.contrib.auth import views as auth_views +from .admin import user_admin_site from .views import index, about_page, contact_page handler500 = 're2o.views.handler500' @@ -61,6 +62,7 @@ urlpatterns = [ url('^', include('django.contrib.auth.urls')), url(r'^i18n/', include('django.conf.urls.i18n')), url(r'^admin/', include(admin.site.urls)), + url(r'^manage/', include(user_admin_site.urls)), url(r'^users/', include('users.urls', namespace='users')), url(r'^search/', include('search.urls', namespace='search')), url(