2018-01-14 12:19:11 +00:00
|
|
|
from django.contrib import admin
|
2018-01-31 09:15:51 +00:00
|
|
|
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
|
|
|
from django.contrib.auth.admin import GroupAdmin as BaseGroupAdmin
|
|
|
|
from django.contrib.auth.models import User, Group
|
2018-01-14 12:19:11 +00:00
|
|
|
|
2018-01-31 09:15:51 +00:00
|
|
|
from .models import UserProfile, SchoolProfile
|
|
|
|
|
|
|
|
# Define an inline admin descriptor for Employee model
|
|
|
|
# which acts a bit like a singleton
|
|
|
|
|
|
|
|
|
|
|
|
class UserInline(admin.StackedInline):
|
|
|
|
model = UserProfile
|
|
|
|
can_delete = False
|
|
|
|
verbose_name_plural = 'user profiles'
|
|
|
|
|
|
|
|
# Define a new User admin
|
|
|
|
|
|
|
|
|
|
|
|
class UserAdmin(BaseUserAdmin):
|
|
|
|
inlines = (UserInline, )
|
|
|
|
|
|
|
|
# Define an inline admin descriptor for Employee model
|
|
|
|
# which acts a bit like a singleton
|
|
|
|
|
|
|
|
|
|
|
|
class SchoolInline(admin.StackedInline):
|
|
|
|
model = SchoolProfile
|
|
|
|
can_delete = False
|
|
|
|
verbose_name_plural = 'schools'
|
|
|
|
|
|
|
|
# Define a new User admin
|
|
|
|
|
|
|
|
|
|
|
|
class GroupAdmin(BaseGroupAdmin):
|
|
|
|
inlines = (SchoolInline, )
|
|
|
|
|
|
|
|
|
|
|
|
# Re-register UserAdmin
|
|
|
|
admin.site.unregister(User)
|
|
|
|
admin.site.register(User, UserAdmin)
|
|
|
|
admin.site.unregister(Group)
|
|
|
|
admin.site.register(Group, GroupAdmin)
|