from django.contrib import admin
from .models import Profile

# Register your models here.

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

from .models import Profile, UserBook

class ProfileInline(admin.StackedInline):
    model = Profile
    can_delete = False
    verbose_name_plural = 'Profile'
    fk_name = 'user'


class CustomUserAdmin(UserAdmin):
    inlines = (ProfileInline, )
    list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff')
    list_select_related = ('profile',)


    def get_inline_instances(self, request, obj=None):
        if not obj:
            return list()
        return super(CustomUserAdmin, self).get_inline_instances(request, obj)

class UserBookModelAdmin(admin.ModelAdmin):
  list_display = ["user", "book"]

  class meta:
    model = UserBook

admin.site.unregister(User)
admin.site.register(User, CustomUserAdmin)
admin.site.register(UserBook, UserBookModelAdmin)



# admin.site.register(Profile)