Admin for non staff
This commit is contained in:
parent
aca1d2def6
commit
80055771e9
11
med/admin.py
11
med/admin.py
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue