47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
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)
|
|
|
|
list_display = ('id','email', "is_staff", "is_active","is_superuser",'status')
|
|
fieldsets = (
|
|
(None, {'fields': ('email','phone','first_name','last_name', 'password','status','avatar')}),
|
|
('Permissions', {'fields': ('is_staff', 'is_active',)}),
|
|
)
|
|
add_fieldsets = (
|
|
(None, {
|
|
'classes': ('wide',),
|
|
'fields': ('email','phone','first_name','last_name', 'password1', 'password2', 'is_staff', 'is_active','status','avatar')}
|
|
),
|
|
)
|
|
ordering = ('email',)
|
|
search_fields = ('email',)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin.site.register(Base_User,CustomUserAdmin)
|
|
admin.site.unregister(Group)
|