from wagtail import hooks
from django.urls import path
from wagtail.admin.menu import MenuItem
from django.urls import reverse

from home.admin_views import (
    ArticleCategoryIndexView,
    ArticleCategoryCreateView,
    ArticleCategoryEditView,
    ArticleCategoryDeleteView,
)


@hooks.register("register_admin_urls")
def register_article_category_admin_urls():
    return [
        path(
            "article-categories/",
            ArticleCategoryIndexView.as_view(),
            name="articlecategory_index",
        ),
        path(
            "article-categories/add/",
            ArticleCategoryCreateView.as_view(),
            name="articlecategory_add",
        ),
        path(
            "article-categories/<int:pk>/edit/",
            ArticleCategoryEditView.as_view(),
            name="articlecategory_edit",
        ),
        path(
            "article-categories/<int:pk>/delete/",
            ArticleCategoryDeleteView.as_view(),
            name="articlecategory_delete",
        ),
    ]


@hooks.register("register_admin_menu_item")
def register_article_category_menu():
    return MenuItem(
        "Article Categories",
        reverse("articlecategory_index"),
        icon_name="tag",
        order=200,
    )