40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
from django.contrib import admin
|
|
from django.contrib.auth.admin import UserAdmin
|
|
|
|
from django.contrib.auth.forms import AdminPasswordChangeForm
|
|
|
|
from .forms import CustomUserChangeForm, CustomUserCreationForm
|
|
# Register your models here.
|
|
|
|
from django.contrib.auth import get_user_model
|
|
|
|
User = get_user_model()
|
|
|
|
|
|
class UserAdmin(UserAdmin):
|
|
add_form = CustomUserCreationForm
|
|
form = CustomUserChangeForm
|
|
model = User
|
|
|
|
list_display = ('email', 'full_name', 'role', 'company', 'email_verified', 'is_active', 'is_staff', 'created', 'last_visit')
|
|
list_filter = ('is_active', 'is_staff', 'email_verified')
|
|
search_fields = ('email', 'full_name', 'company__short_name')
|
|
readonly_fields = ['modified','created','last_visit']
|
|
|
|
fieldsets = (
|
|
(None, {'fields': ('email', 'password','full_name', 'role', 'notify','provider','email_verified','company','is_active')}),
|
|
('Permissions', {'fields': ('is_staff', 'groups')}),
|
|
)
|
|
|
|
add_fieldsets = (
|
|
(None, {
|
|
'classes': ('wide',),
|
|
'fields': ('email', 'password1', 'password2', 'full_name', 'role', 'company', 'email_verified', 'is_active', 'is_staff')}
|
|
),
|
|
)
|
|
|
|
ordering = ('email',)
|
|
|
|
|
|
admin.site.register(User, UserAdmin)
|