from django.contrib import admin

from django.contrib.auth.admin import UserAdmin

# Register your models here.

from usuarios.models import Usuario
from usuarios.forms import UsuarioCreationForm, UsuarioChangeForm


class UsuarioAdmin(UserAdmin):
    add_form = UsuarioCreationForm
    form = UsuarioChangeForm
    model = Usuario
    list_display = ("email", "nombre", "is_staff", "is_active", "foto")
    list_filter = ("email", "nombre", "is_staff", "is_active",)
    fieldsets = (
        (None, {"fields": ("email", "password")}),
        ("Personal", {"fields": ("nombre",)}),
        ("Permissions", {"fields": ("is_staff", "is_active", "groups",
                                    "user_permissions")}),
        ("Varios", {"fields": ("foto",)}),
    )
    add_fieldsets = (
        (
            None,
            {
                "classes": ("wide",),
                "fields": (
                    "email", "password1", "password2", "is_staff",
                    "is_active", "groups", "user_permissions"
                )
            }
        ),

        ("Personal", {"fields": ("nombre",)}),
        ("Varios", {"fields": ("foto",)}),
    )
    search_fields = ("email",)
    ordering = ("email",)


admin.site.register(Usuario, UsuarioAdmin)
