2020-12-07 21:41:55 +01:00
|
|
|
from django.contrib import admin
|
|
|
|
from .models import Base_User, OwnerUser, NormalUser
|
|
|
|
from .forms import CustomUserCreationForm, CustomUserChangeForm
|
|
|
|
from django.contrib.auth.admin import UserAdmin
|
|
|
|
from django.contrib.auth.models import Group
|
|
|
|
|
|
|
|
class NormalUserInline(admin.StackedInline):
|
|
|
|
model = NormalUser
|
|
|
|
can_delete = False
|
|
|
|
verbose_name_plural = 'Normal user'
|
|
|
|
|
|
|
|
class OwnerUserInLine(admin.StackedInline):
|
|
|
|
model = OwnerUser
|
|
|
|
can_delete = False
|
|
|
|
verbose_name_plural = 'Owner user'
|
|
|
|
|
|
|
|
|
|
|
|
class CustomUserAdmin(UserAdmin):
|
|
|
|
add_form = CustomUserCreationForm
|
|
|
|
form = CustomUserChangeForm
|
|
|
|
model = Base_User
|
|
|
|
|
|
|
|
inlines = (NormalUserInline,OwnerUserInLine)
|
|
|
|
|
2020-12-27 01:33:07 +01:00
|
|
|
list_display = ('email', "is_staff", "is_active","is_superuser",'status')
|
2020-12-07 21:41:55 +01:00
|
|
|
fieldsets = (
|
|
|
|
(None, {'fields': ('email', 'password')}),
|
|
|
|
('Permissions', {'fields': ('is_staff', 'is_active')}),
|
|
|
|
)
|
|
|
|
add_fieldsets = (
|
|
|
|
(None, {
|
|
|
|
'classes': ('wide',),
|
|
|
|
'fields': ('email', 'password1', 'password2', 'is_staff', 'is_active')}
|
|
|
|
),
|
|
|
|
)
|
|
|
|
ordering = ('email',)
|
|
|
|
search_fields = ('email',)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin.site.register(Base_User,CustomUserAdmin)
|
|
|
|
admin.site.unregister(Group)
|