from django.contrib import admin
from django.contrib.auth import get_user_model
from usuarios.forms import UserChangeForm, FormCreacionUsuario
from django.contrib.auth.admin import UserAdmin
Usuario = get_user_model()


class UserAdminModel(UserAdmin):
    # The forms to add and change user instances
    form = UserChangeForm
    add_form = FormCreacionUsuario

    # The fields to be used in displaying the User model.
    # These override the definitions on the base UserAdmin
    # that reference specific fields on auth.User.
    list_display = ('username',)
    fieldsets = (
        (None, {'fields': ('username', 'password')}),
        ('Información personal', {'fields': ('nombre', 'tipo',)}),
    )
    # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin
    # overrides get_fieldsets to use this attribute when creating a user.
    add_fieldsets = (
        (None, {
            'classes': ('wide',),
            'fields': ('username', 'nombre', 'tipo', 'password1', 'password2')
        }),
    )
    search_fields = ('username',)
    ordering = ('username',)
    filter_horizontal = ()

# Register your models here.
admin.site.register(Usuario, UserAdminModel)