from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import ParadiseUser


@admin.register(ParadiseUser)
class ParadiseUserAdmin(UserAdmin):
    list_display = ('username', 'phone_number', 'email', 'is_staff', 'is_active', 'date_joined')
    list_filter = ('is_staff', 'is_active', 'date_joined')
    search_fields = ('username', 'phone_number', 'email')
    ordering = ('-date_joined',)

    fieldsets = (
        ('基本信息', {'fields': ('username', 'password')}),
        ('个人信息', {'fields': ('phone_number', 'email')}),
        ('权限', {
            'fields': ('is_active', 'is_staff', 'is_superuser', 'groups', 'user_permissions'),
        }),
        ('重要日期', {'fields': ('last_login', 'date_joined')}),
    )

    add_fieldsets = (
        ('新建用户', {
            'classes': ('wide',),
            'fields': ('username', 'phone_number', 'password1', 'password2'),
        }),
    )

    class Meta:
        verbose_name = '用户'
        verbose_name_plural = '用户管理'

