from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from .models import Post, Comment, UserProfile


class PostAdmin(admin.ModelAdmin):
    fieldsets = (
        (None,
         {'fields': ('title', 'text', 'tags', 'image', 'author', 'published_date', 'created_date')}),
    )


admin.site.register(Post, PostAdmin)
admin.site.register(Comment)


class UserInline(admin.StackedInline):
    model = UserProfile
    can_delete = False
    verbose_name_plural = 'Доп. информация'

# Определяем новый класс настроек для модели User
class UserAdmin(UserAdmin):
    inlines = (UserInline, )

# Перерегистрируем модель User
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
