Project_Camper/vagus/users/admin.py

47 lines
1.3 KiB
Python
Raw Normal View History

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)
2021-01-17 17:10:04 +01:00
list_display = ('id','email', "is_staff", "is_active","is_superuser",'status')
2020-12-07 21:41:55 +01:00
fieldsets = (
2021-01-27 20:09:55 +01:00
(None, {'fields': ('email','phone','first_name','last_name', 'password','status','avatar')}),
2021-01-17 17:10:04 +01:00
('Permissions', {'fields': ('is_staff', 'is_active',)}),
2020-12-07 21:41:55 +01:00
)
add_fieldsets = (
(None, {
'classes': ('wide',),
2021-01-27 20:09:55 +01:00
'fields': ('email','phone','first_name','last_name', 'password1', 'password2', 'is_staff', 'is_active','status','avatar')}
2020-12-07 21:41:55 +01:00
),
)
ordering = ('email',)
search_fields = ('email',)
admin.site.register(Base_User,CustomUserAdmin)
admin.site.unregister(Group)