mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-28 15:42:25 +00:00
Create custom ModelAdmin class
This commit is contained in:
parent
3a28e4aebc
commit
040b15dcd1
2 changed files with 11 additions and 8 deletions
|
@ -1,10 +1,16 @@
|
|||
from django.contrib.admin.sites import AdminSite
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
class UserAdmin(AdminSite):
|
||||
class UserAdmin(admin.sites.AdminSite):
|
||||
def has_permission(self, request):
|
||||
"""This admin site doesn't require being staff"""
|
||||
return request.user.is_active
|
||||
|
||||
|
||||
class ModelUserAdmin(admin.ModelAdmin):
|
||||
# Display actions on changelist bottom bu default
|
||||
actions_on_bottom = True
|
||||
|
||||
|
||||
# Defines new management site
|
||||
user_admin_site = UserAdmin(name='user_admin')
|
||||
|
|
|
@ -32,8 +32,7 @@ from django.contrib.auth.models import Group
|
|||
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
||||
from reversion.admin import VersionAdmin
|
||||
|
||||
from useradmin.admin import user_admin_site
|
||||
|
||||
from useradmin.admin import ModelUserAdmin, user_admin_site
|
||||
from .models import (
|
||||
User,
|
||||
EMailAddress,
|
||||
|
@ -85,10 +84,9 @@ class LdapServiceUserGroupAdmin(admin.ModelAdmin):
|
|||
search_fields = ('name',)
|
||||
|
||||
|
||||
class SchoolAdmin(VersionAdmin):
|
||||
class SchoolAdmin(VersionAdmin, ModelUserAdmin):
|
||||
"""Administration, gestion des écoles"""
|
||||
list_display = ('name',)
|
||||
actions_on_bottom = True
|
||||
|
||||
|
||||
class ListRightAdmin(VersionAdmin):
|
||||
|
@ -97,10 +95,9 @@ class ListRightAdmin(VersionAdmin):
|
|||
list_display = ('unix_name',)
|
||||
|
||||
|
||||
class ListShellAdmin(VersionAdmin):
|
||||
class ListShellAdmin(VersionAdmin, ModelUserAdmin):
|
||||
"""Gestion de la liste des shells coté admin"""
|
||||
list_display = ('shell',)
|
||||
actions_on_bottom = True
|
||||
|
||||
|
||||
class RequestAdmin(admin.ModelAdmin):
|
||||
|
|
Loading…
Reference in a new issue