Admin for non staff

This commit is contained in:
Alexandre Iooss 2019-08-10 09:51:46 +02:00
parent aca1d2def6
commit 80055771e9
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
1 changed files with 11 additions and 0 deletions

View File

@ -3,6 +3,8 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
from django.contrib.admin import AdminSite from django.contrib.admin import AdminSite
from django.contrib.auth.admin import Group, GroupAdmin
from django.contrib.sites.admin import Site, SiteAdmin
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.views.decorators.cache import never_cache from django.views.decorators.cache import never_cache
@ -25,5 +27,14 @@ class DatabaseAdmin(AdminSite):
return response return response
def has_permission(self, request):
"""
Authorize all active user to access admin
"""
return request.user.is_active
# Instantiate admin site and register some defaults
admin_site = DatabaseAdmin() admin_site = DatabaseAdmin()
admin_site.register(Group, GroupAdmin)
admin_site.register(Site, SiteAdmin)