from django.urls import path, register_converter
from . import tag_views


class UnicodeSlugConverter:
    """Path converter that accepts Unicode characters in slugs, including Chinese, Japanese, etc."""
    regex = r'[-\w]+'  # \w includes Unicode word characters
    
    def to_python(self, value):
        return value

    def to_url(self, value):
        return value


register_converter(UnicodeSlugConverter, 'uslug')

urlpatterns = [
    path('ui/tags/', tag_views.TagListView.as_view(), name='tag-list'),
    path('ui/tags/new/', tag_views.TagCreateView.as_view(), name='tag-create'),
    path('ui/tags/<uslug:slug>/', tag_views.TagDetailView.as_view(), name='tag-detail'),
    path('ui/tags/<uslug:slug>/edit/', tag_views.TagUpdateView.as_view(), name='tag-update'),
    path('ui/tags/<uslug:slug>/delete/', tag_views.TagDeleteView.as_view(), name='tag-delete'),
]
