import taggit.admin

from django.contrib import admin, auth
from django.contrib.flatpages.admin import FlatPageAdmin
from django.contrib.flatpages.models import FlatPage
from django.contrib.sites.models import Site
from django.utils.translation import gettext_lazy as _

from .forms import FlatPageForm
from .models import CustomFlatPage


# Define a new FlatPageAdmin
class CustomFlatPageAdmin(FlatPageAdmin):
    form = FlatPageForm
    fieldsets = (
        (
            None,
            {
                "fields": (
                    "url",
                    "title",
                    "content",
                )
            },
        ),
        (
            _("Advanced options"),
            {
                "classes": ("collapse",),
                "fields": ("registration_required", "template_name"),
            },
        ),
    )
    list_display = ["url", "title", "registration_required"]
    list_filter = ("registration_required",)


# Re-register FlatPageAdmin
admin.site.unregister(FlatPage)
admin.site.register(CustomFlatPage, CustomFlatPageAdmin)

admin.site.unregister(Site)

admin.site.unregister(auth.models.User)
admin.site.unregister(auth.models.Group)
admin.site.unregister(taggit.models.Tag)
