from django.contrib.auth.decorators import login_required
from django.urls import path

from newsreader.news.collection.endpoints import (
    DetailRuleView,
    NestedRuleView,
    RuleReadView,
)
from newsreader.news.collection.views import (
    CollectionRuleBulkDeleteView,
    CollectionRuleBulkDisableView,
    CollectionRuleBulkEnableView,
    CollectionRuleListView,
    FeedCreateView,
    FeedUpdateView,
    OPMLImportView,
)


endpoints = [
    path("rules/<int:pk>/", DetailRuleView.as_view(), name="rules-detail"),
    path("rules/<int:pk>/posts/", NestedRuleView.as_view(), name="rules-nested-posts"),
    path("rules/<int:pk>/read/", RuleReadView.as_view(), name="rules-read"),
]

urlpatterns = [
    # Feeds
    path(
        "feeds/<int:pk>/", login_required(FeedUpdateView.as_view()), name="feed-update"
    ),
    path("feeds/create/", login_required(FeedCreateView.as_view()), name="feed-create"),
    # Generic rules
    path("rules/", login_required(CollectionRuleListView.as_view()), name="rules"),
    path(
        "rules/delete/",
        login_required(CollectionRuleBulkDeleteView.as_view()),
        name="rules-delete",
    ),
    path(
        "rules/enable/",
        login_required(CollectionRuleBulkEnableView.as_view()),
        name="rules-enable",
    ),
    path(
        "rules/disable/",
        login_required(CollectionRuleBulkDisableView.as_view()),
        name="rules-disable",
    ),
    path("rules/import/", login_required(OPMLImportView.as_view()), name="import"),
]
