from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as AuthUserAdmin
from django.contrib.auth.forms import UserChangeForm, UserCreationForm

from users import models


class MyUserChangeForm(UserChangeForm):
    class Meta(UserChangeForm.Meta):
        model = models.User


class MyUserCreationForm(UserCreationForm):
    class Meta(UserCreationForm.Meta):
        model = models.User


@admin.register(models.User)
class UserAdmin(AuthUserAdmin):
    form = MyUserChangeForm
    list_display = ('username', 'first_name', 'last_name', 'email', 'uid', )



@admin.register(models.ConfirmationCode)
class ConfirmationCodeAdmin(admin.ModelAdmin):
    list_display = ('code', 'email', 'registration_id')
    search_fields = ('code', 'email')
    list_filter = ('registration_id', )
    list_display_links = ('code',)


@admin.register(models.SecurityCode)
class SecurityCodeAdmin(admin.ModelAdmin):
    list_display = ('email', 'code')
    search_fields = ('code', 'email')
